diff --git a/account_customer_wallet/README.rst b/account_customer_wallet/README.rst deleted file mode 100644 index abae389a1..000000000 --- a/account_customer_wallet/README.rst +++ /dev/null @@ -1,97 +0,0 @@ -======================= -Account Customer Wallet -======================= - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:b7bc4c73dc40a6013af0515a28f25abe38fba21bf357c12a98693a84750f4059 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png - :target: https://odoo-community.org/page/development-status - :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github - :target: https://github.com/coopiteasy/addons/tree/16.0/account_customer_wallet - :alt: coopiteasy/addons - -|badge1| |badge2| |badge3| - -Allow customers to pay using a wallet which is tracked by the company. - -**Table of contents** - -.. contents:: - :local: - -Configuration -============= - -Setting this up requires a few careful steps: - -- Make sure your user has access to all accounting features. -- Create an account (Customer Wallet) that is a liability. -- Create a journal (Customer Wallet). Enable the 'Customer Wallet Journal' - toggle, set the Bank Account to the previously created account, and in the - payment methods (both incoming and outgoing), set the Outstanding Receipts and - Outstanding Payments accounts to the previously created account. You may need - to toggle the visibility of these fields in the tables. -- In the Invoicing settings, set the Customer Wallet Account to the previously - created account. -- (Optional) Create a product (Wallet Product), and enable the Wallet Product - toggle. Set the income and expense account to the previously created account. - -Changelog -========= - -12.0.1.2.0 (2022-07-08) -~~~~~~~~~~~~~~~~~~~~~~~ - -**Misc** - -- `#237 `_ - - -12.0.1.1.0 (2022-06-23) -**Features** - -- Make ``customer_wallet_balance`` searchable, and add a filter for non-zero - balances. (`#235 `_) - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -~~~~~~~ - -* Coop IT Easy SC -* GRAP - -Contributors -~~~~~~~~~~~~ - -* `Coop IT Easy SC `_: - - * Carmen Bianca Bakker - -Maintainers -~~~~~~~~~~~ - -This module is part of the `coopiteasy/addons `_ project on GitHub. - -You are welcome to contribute. diff --git a/account_customer_wallet/demo/account_journal_demo.xml b/account_customer_wallet/demo/account_journal_demo.xml deleted file mode 100644 index 7928c7c13..000000000 --- a/account_customer_wallet/demo/account_journal_demo.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Customer Wallet - WLLT - bank - - - 30 - - - - - diff --git a/account_customer_wallet/i18n/account_customer_wallet.pot b/account_customer_wallet/i18n/account_customer_wallet.pot deleted file mode 100644 index 68e23d196..000000000 --- a/account_customer_wallet/i18n/account_customer_wallet.pot +++ /dev/null @@ -1,135 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_customer_wallet -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_partner__account_move_line_ids -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_users__account_move_line_ids -msgid "Account Move Line" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,help:account_customer_wallet.field_product_product__is_customer_wallet_product -#: model:ir.model.fields,help:account_customer_wallet.field_product_template__is_customer_wallet_product -msgid "" -"Check this box if this product is used to credit customer wallets. Important" -" note : you should set the the same income and expense account as the " -"journal wallet." -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_res_company -msgid "Companies" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_res_config_settings -msgid "Config Settings" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_res_partner -msgid "Contact" -msgstr "" - -#. module: account_customer_wallet -#: model_terms:ir.ui.view,arch_db:account_customer_wallet.view_partner_form -msgid "Customer Wallet" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_company__customer_wallet_account_id -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_config_settings__customer_wallet_account_id -msgid "Customer Wallet Account" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_payment__customer_wallet_balance -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_partner__customer_wallet_balance -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_users__customer_wallet_balance -msgid "Customer Wallet Balance" -msgstr "" - -#. module: account_customer_wallet -#: model_terms:ir.ui.view,arch_db:account_customer_wallet.view_res_partner_filter -msgid "Customer Wallet Balance Not Zero" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_journal__is_customer_wallet_journal -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_payment__is_customer_wallet_journal -msgid "Customer Wallet Journal" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_company__is_enabled_customer_wallet -msgid "Is Customer Wallet Enabled" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_account_journal -msgid "Journal" -msgstr "" - -#. module: account_customer_wallet -#: model_terms:ir.ui.view,arch_db:account_customer_wallet.res_config_settings_view_form -msgid "Let customers pay from a wallet account" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_journal__minimum_wallet_amount -msgid "Minimum Wallet Amount" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_account_payment -msgid "Payments" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_product_template -msgid "Product" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,help:account_customer_wallet.field_res_config_settings__customer_wallet_account_id -msgid "The account where all wallet transactions will be recorded" -msgstr "" - -#. module: account_customer_wallet -#. odoo-python -#: code:addons/account_customer_wallet/models/account_payment.py:0 -#, python-format -msgid "" -"There is not enough balance in the customer's wallet to perform this payment. \n" -" - Customer : %(partner)s\n" -" - Customer Wallet : %(balance)s\n" -" - Amount Payment : %(amount)s" -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,help:account_customer_wallet.field_account_journal__minimum_wallet_amount -msgid "" -"Usually 0. You can enter a negative value, if you want to accept that the " -"customer wallet is negative. Maybe useful if the sale amount is slightly " -"higher than the wallet amount, to avoid charging the customer a small " -"amount." -msgstr "" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_product_product__is_customer_wallet_product -#: model:ir.model.fields,field_description:account_customer_wallet.field_product_template__is_customer_wallet_product -#: model:product.template,name:account_customer_wallet.product_wallet_demo_product_template -msgid "Wallet Product" -msgstr "" diff --git a/account_customer_wallet/i18n/fr.po b/account_customer_wallet/i18n/fr.po deleted file mode 100644 index f27693f8d..000000000 --- a/account_customer_wallet/i18n/fr.po +++ /dev/null @@ -1,132 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * account_customer_wallet -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-09-12 21:29+0000\n" -"PO-Revision-Date: 2022-09-12 21:29+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: account_customer_wallet -#: model:ir.model.fields,help:account_customer_wallet.field_product_product__is_customer_wallet_product -#: model:ir.model.fields,help:account_customer_wallet.field_product_template__is_customer_wallet_product -msgid "Check this box if this product is used to credit customer wallets. Important note : you should set the the same income and expense account as the journal wallet." -msgstr "Cochez cette case si ce produit est utilisé pour créditer des comptes clients. Note importante : vous devez mettre le même compte comptable de dépense et de revenue que pour le journal de compte client." - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_res_company -msgid "Companies" -msgstr "Sociétés" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_res_config_settings -msgid "Config Settings" -msgstr "Paramètres de config" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_res_partner -msgid "Contact" -msgstr "" - -#. module: account_customer_wallet -#: model_terms:ir.ui.view,arch_db:account_customer_wallet.view_partner_form -msgid "Customer Wallet" -msgstr "Compte client" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_company__customer_wallet_account_id -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_config_settings__customer_wallet_account_id -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_partner__customer_wallet_account_id -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_users__customer_wallet_account_id -msgid "Customer Wallet Account" -msgstr "Compte comptable du compte client" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_payment__customer_wallet_balance -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_partner__customer_wallet_balance -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_users__customer_wallet_balance -msgid "Customer Wallet Balance" -msgstr "Solde du compte client" - -#. module: account_customer_wallet -#: model_terms:ir.ui.view,arch_db:account_customer_wallet.view_res_partner_filter -msgid "Customer Wallet Balance Not Zero" -msgstr "Compte client non nul" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_bank_statement_import_journal_creation__is_customer_wallet_journal -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_journal__is_customer_wallet_journal -#: model:ir.model.fields,field_description:account_customer_wallet.field_account_payment__is_customer_wallet_journal -msgid "Customer Wallet Journal" -msgstr "Journal de compte client" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_res_company__is_enabled_customer_wallet -msgid "Is Customer Wallet Enabled" -msgstr "Compte client activé" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_account_journal -msgid "Journal" -msgstr "" - -#. module: account_customer_wallet -#: model_terms:ir.ui.view,arch_db:account_customer_wallet.res_config_settings_view_form -msgid "Let customers pay from a wallet account" -msgstr "Autoriser les clients à payer avec un compte client" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_account_payment -msgid "Payments" -msgstr "Paiements" - -#. module: account_customer_wallet -#: model:ir.model,name:account_customer_wallet.model_product_template -msgid "Product Template" -msgstr "Modèle d'article" - -#. module: account_customer_wallet -#: model:ir.model.fields,help:account_customer_wallet.field_res_config_settings__customer_wallet_account_id -msgid "The account where all wallet transactions will be recorded" -msgstr "Le compte dans lequel toutes les transactions de compte client seront enregistrés" - -#. module: account_customer_wallet -#: code:addons/account_customer_wallet/models/account_payment.py:31 -#, python-format -msgid "There is not enough balance in the customer's wallet to perform this payment. \n" -" - Customer : %s\n" -" - Customer Wallet : %s\n" -" - Amount Payment : %s" -msgstr "Il n'y a pas assez d'argent sur le compte client de ce partenaire, pour valider ce paiement. \n" -" - Client : %s\n" -" - Solde du compte client : %s\n" -" - Montant du paiement : %s" - -#. module: account_customer_wallet -#: model:product.product,uom_name:account_customer_wallet.product_wallet_demo -#: model:product.template,uom_name:account_customer_wallet.product_wallet_demo_product_template -msgid "Unit(s)" -msgstr "Unité(s)" - -#. module: account_customer_wallet -#: model:ir.model.fields,field_description:account_customer_wallet.field_product_product__is_customer_wallet_product -#: model:ir.model.fields,field_description:account_customer_wallet.field_product_template__is_customer_wallet_product -#: model:product.product,name:account_customer_wallet.product_wallet_demo -#: model:product.template,name:account_customer_wallet.product_wallet_demo_product_template -msgid "Wallet Product" -msgstr "Crédit de compte client" - -#. module: account_customer_wallet -#: model:product.product,weight_uom_name:account_customer_wallet.product_wallet_demo -#: model:product.template,weight_uom_name:account_customer_wallet.product_wallet_demo_product_template -msgid "kg" -msgstr "" - diff --git a/account_customer_wallet/models/product_template.py b/account_customer_wallet/models/product_template.py deleted file mode 100644 index d5ca78606..000000000 --- a/account_customer_wallet/models/product_template.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2022-Today: GRAP (http://www.grap.coop) -# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import fields, models - - -class ProductTemplate(models.Model): - _inherit = "product.template" - - is_customer_wallet_product = fields.Boolean( - string="Wallet Product", - help="Check this box if this product is used to credit" - " customer wallets. Important note : you should set the" - " the same income and expense account as the journal wallet.", - ) diff --git a/account_customer_wallet/models/res_partner.py b/account_customer_wallet/models/res_partner.py deleted file mode 100644 index 0977d5e4a..000000000 --- a/account_customer_wallet/models/res_partner.py +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright 2022 Coop IT Easy SC -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -from collections import defaultdict - -from odoo import api, fields, models -from odoo.tools.safe_eval import safe_eval - - -class Partner(models.Model): - _inherit = "res.partner" - - customer_wallet_balance = fields.Monetary( - compute="_compute_customer_wallet_balance", - readonly=True, - recursive=True, - search="_search_customer_wallet_balance", - default=0, - ) - account_move_line_ids = fields.One2many( - comodel_name="account.move.line", - inverse_name="partner_id", - readonly=True, - ) - - def get_topmost_parent_id(self): - self.ensure_one() - if not self.parent_id: - return self - return self.parent_id.get_topmost_parent_id() - - def get_all_partners_in_family(self): - self.ensure_one() - return ( - self.with_context(active_test=False) - .search([("id", "child_of", self.get_topmost_parent_id().id)]) - .ids - ) - - def get_wallet_balance_account_move_line(self, all_partner_ids, wallet_account_id): - pre_result = defaultdict(float) - for line in ( - self.env["account.move.line"] - .sudo() - .search( - [ - ("partner_id", "in", list(all_partner_ids)), - # Check state - ("parent_state", "=", "posted"), - # FIXME: This should ideally be something like - # `("account_id", "=", partner.customer_wallet_account_id)`, - # but that may not be possible. - ("account_id", "=", wallet_account_id.id), - ] - ) - ): - pre_result[line.partner_id.id] += line.balance - return [ - {"partner_id": partner_id, "total": total} - for partner_id, total in pre_result.items() - ] - - def get_wallet_balance_all(self, all_partner_ids, wallet_account_id): - # Overload in other modules (like pos_customer_wallet) - return [ - self.get_wallet_balance_account_move_line( - all_partner_ids, wallet_account_id - ) - ] - - def _customer_wallet_balance_depends(self): - return [ - "account_move_line_ids", - "account_move_line_ids.account_id", - "account_move_line_ids.balance", - "account_move_line_ids.parent_state", - "child_ids", - "child_ids.customer_wallet_balance", - "parent_id", - "parent_id.customer_wallet_balance", - ] - - @api.depends(lambda self: self._customer_wallet_balance_depends()) - @api.depends_context("company") - def _compute_customer_wallet_balance(self): - wallet_account_id = self.env.company.customer_wallet_account_id - if not wallet_account_id or not self.ids: - # Always assign a value in a compute method. - self.write({"customer_wallet_balance": 0.0}) - return - - all_partner_families = {} - all_partner_ids = set() - - # we split the calculation in two part to optimize it - # because the call of get_all_partners_in_family take time - # and is not necessary for most partners - for partner in self.filtered(lambda x: x.parent_id or x.child_ids): - all_partner_families[partner] = partner.get_all_partners_in_family() - all_partner_ids |= set(all_partner_families[partner]) - - for partner in self.filtered(lambda x: not x.parent_id and not x.child_ids): - all_partner_families[partner] = [partner.id] - all_partner_ids |= set(all_partner_families[partner]) - - all_totals = self.get_wallet_balance_all(all_partner_ids, wallet_account_id) - - for partner, child_ids in all_partner_families.items(): - wallet_balance = 0.0 - for totals in all_totals: - wallet_balance += sum( - -total["total"] - for total in totals - if total["partner_id"] in child_ids - ) - partner.customer_wallet_balance = wallet_balance - - def _search_customer_wallet_balance(self, operator, value): - # This is a complete and utter hack. Don't do what I did. - if operator in ("=", "!=", ">", ">=", "<", "<=", "=?", "in", "not in"): - if operator in ("=", "=?"): - operator = "==" - filter_string = "partner.customer_wallet_balance {operator} {value}".format( - operator=operator, value=value - ) - filtered = self.search([]).filtered( - lambda partner: safe_eval( - filter_string, - {"partner": partner}, - ) - ) - if filtered: - return [("id", "in", [partner.id for partner in filtered])] - else: - # TODO maybe - raise NotImplementedError() diff --git a/account_customer_wallet/readme/DESCRIPTION.rst b/account_customer_wallet/readme/DESCRIPTION.rst deleted file mode 100644 index a3b65eda4..000000000 --- a/account_customer_wallet/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -Allow customers to pay using a wallet which is tracked by the company. diff --git a/account_customer_wallet/views/res_partner_views.xml b/account_customer_wallet/views/res_partner_views.xml deleted file mode 100644 index c6890096c..000000000 --- a/account_customer_wallet/views/res_partner_views.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - account_customer_wallet.view_partner_form - res.partner - - - - - - - - - - - - account_customer_wallet.partner.search.form - res.partner - - - - - - - - - diff --git a/customer_wallet/README.rst b/customer_wallet/README.rst new file mode 100644 index 000000000..8af1180a8 --- /dev/null +++ b/customer_wallet/README.rst @@ -0,0 +1,164 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=============== +Customer Wallet +=============== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b7bc4c73dc40a6013af0515a28f25abe38fba21bf357c12a98693a84750f4059 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github + :target: https://github.com/coopiteasy/addons/tree/16.0/customer_wallet + :alt: coopiteasy/addons + +|badge1| |badge2| |badge3| + +Allow customers to pay using a wallet which is tracked by the company. + +A wallet is a cash advance provided by the customer, +which can be used to make purchases at a later date. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +Setting this up requires a few careful steps: + +- Make sure your user has access to all accounting features. +- Create an account (Customer Wallet) that is a liability. + .. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/configure_account_account.png + In France, the account generally used will be "4197" - "Clients – Autres avoirs". +- Create a journal (Customer Wallet). Enable the 'Customer Wallet Journal' + toggle, set the Bank Account to the previously created account, and in the + payment methods (both incoming and outgoing), set the Outstanding Receipts and + Outstanding Payments accounts to the previously created account. You may need + to toggle the visibility of these fields in the tables. + .. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/configure_account_journal.png +- In the Invoicing settings, set the Customer Wallet Account to the previously + created account. + .. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/configure_res_config_settings.png +- (Optional) Create a product (Wallet Product), and enable the Wallet Product + toggle. The income and expense accounts will be automatically set to the Customer + Wallet Account previously created. + .. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/configure_product_template.png + +Usage +===== + +**Credit Customer Wallet** + +- Create a new customer invoice +- Select the Customer Wallet Product and put an amount +- Confirm the invoice + + .. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/invoice_form_wallet_sale.png + +As a result, the customer has now a credit amount in his customer wallet. + +You can then check Customer Wallet amount on the partner form. + +- Select your customer + +- Open the 'Sale & Purchase' Tab + + .. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/partner_form_wallet_amount.png + +You can also see all the Customer Wallets: + +- Click on 'Accounting > Customers > Customer Wallets' + + .. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/partner_tree_wallet_amount.png + +**Debit Customer Wallet** + +You can then mark a customer invoice as paid, using the account journal 'Customer Wallet'. + +A message is present in the payment wizard. + +.. figure:: https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/payment_form.png + +Known issues / Roadmap +====================== + +* Improve demo / test data for accountings items. + See: complete reflection + https://github.com/coopiteasy/addons/pull/397#discussion_r2894692265 + +Changelog +========= + +12.0.1.2.0 (2022-07-08) +~~~~~~~~~~~~~~~~~~~~~~~ + +**Misc** + +- `#237 `_ + + +12.0.1.1.0 (2022-06-23) +**Features** + +- Make ``customer_wallet_balance`` searchable, and add a filter for non-zero + balances. (`#235 `_) + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Coop IT Easy SC +* GRAP + +Contributors +~~~~~~~~~~~~ + +* `Coop IT Easy SC `_: + * Carmen Bianca Bakker +* `GRAP `_: + * Sylvain LE GAL + +Maintainers +~~~~~~~~~~~ + +.. |maintainer-carmenbianca| image:: https://github.com/carmenbianca.png?size=40px + :target: https://github.com/carmenbianca + :alt: carmenbianca +.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain + +Current maintainers: + +|maintainer-carmenbianca| |maintainer-legalsylvain| + +This module is part of the `coopiteasy/addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/customer_wallet/__init__.py b/customer_wallet/__init__.py new file mode 100644 index 000000000..aee8895e7 --- /dev/null +++ b/customer_wallet/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/account_customer_wallet/__manifest__.py b/customer_wallet/__manifest__.py similarity index 66% rename from account_customer_wallet/__manifest__.py rename to customer_wallet/__manifest__.py index 7820c8ff2..82b2b413b 100644 --- a/account_customer_wallet/__manifest__.py +++ b/customer_wallet/__manifest__.py @@ -2,13 +2,14 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - "name": "Account Customer Wallet", + "name": "Customer Wallet", "summary": """ Allow customers to pay using a wallet which is tracked by the company.""", - "version": "16.0.1.0.1", - "category": "Accounting & Finance", + "version": "16.0.1.0.0", + "category": "Accounting/Accounting", "website": "https://github.com/coopiteasy/addons", - "author": "Coop IT Easy SC,GRAP", + "author": "Coop IT Easy SC, GRAP", + "maintainers": ["carmenbianca", "legalsylvain"], "license": "AGPL-3", "application": False, "depends": [ @@ -16,11 +17,15 @@ ], "excludes": [], "data": [ + "security/ir.model.access.csv", "views/account_journal_views.xml", "views/account_payment_views.xml", "views/product_template_views.xml", - "views/res_config_settings_views.xml", "views/res_partner_views.xml", + "views/res_config_settings_views.xml", + "wizards/account_payment_register_views.xml", + "wizards/customer_wallet_detail_wizard_views.xml", + "wizards/customer_wallet_redistribute_views.xml", ], "demo": [ "demo/account_account_demo.xml", diff --git a/account_customer_wallet/demo/account_account_demo.xml b/customer_wallet/demo/account_account_demo.xml similarity index 100% rename from account_customer_wallet/demo/account_account_demo.xml rename to customer_wallet/demo/account_account_demo.xml diff --git a/customer_wallet/demo/account_journal_demo.xml b/customer_wallet/demo/account_journal_demo.xml new file mode 100644 index 000000000..e32e7ef9f --- /dev/null +++ b/customer_wallet/demo/account_journal_demo.xml @@ -0,0 +1,27 @@ + + + + + Customer Wallet + WLLT + bank + + + 30 + + + + + diff --git a/account_customer_wallet/demo/product_product_demo.xml b/customer_wallet/demo/product_product_demo.xml similarity index 100% rename from account_customer_wallet/demo/product_product_demo.xml rename to customer_wallet/demo/product_product_demo.xml diff --git a/account_customer_wallet/demo/res_company_demo.xml b/customer_wallet/demo/res_company_demo.xml similarity index 65% rename from account_customer_wallet/demo/res_company_demo.xml rename to customer_wallet/demo/res_company_demo.xml index d06ce32e9..8a5065fcf 100644 --- a/account_customer_wallet/demo/res_company_demo.xml +++ b/customer_wallet/demo/res_company_demo.xml @@ -2,9 +2,9 @@ - diff --git a/customer_wallet/i18n/fr.po b/customer_wallet/i18n/fr.po new file mode 100644 index 000000000..dc3339f43 --- /dev/null +++ b/customer_wallet/i18n/fr.po @@ -0,0 +1,425 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * customer_wallet +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-09-12 21:29+0000\n" +"PO-Revision-Date: 2022-09-12 21:29+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_partner_form +msgid "Wallet" +msgstr "Porte-monnaie" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_res_partner__account_move_line_ids +#: model:ir.model.fields,field_description:customer_wallet.field_res_users__account_move_line_ids +msgid "Account Move Line" +msgstr "Ligne d'écriture" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_detail_wizard.py:0 +#, python-format +msgid "Amount" +msgstr "Montant" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__amount +msgid "Amount to receive" +msgstr "Montant à recevoir" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_detail_wizard.py:0 +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__customer_wallet_balance +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__customer_wallet_balance +#, python-format +msgid "Balance" +msgstr "Solde" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_customer_wallet_redistribute_wizard_form +msgid "Beneficiaries" +msgstr "Bénéficiaires" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_customer_wallet_redistribute_wizard_form +msgid "Cancel" +msgstr "Annuler" + +#. module: customer_wallet +#: model:ir.model.fields,help:customer_wallet.field_product_product__is_customer_wallet_product +#: model:ir.model.fields,help:customer_wallet.field_product_template__is_customer_wallet_product +msgid "Check this box if this product is used to credit customer wallets." +msgstr "" +"Cochez cette case si ce produit est utilisé pour créditer des porte-monnaies " +"client." + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_res_config_settings +msgid "Config Settings" +msgstr "Paramètres de configuration" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__create_uid +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__create_uid +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__create_date +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__create_date +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__create_date +msgid "Created on" +msgstr "Créé le" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__currency_id +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__currency_id +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__currency_id +msgid "Currency" +msgstr "Devise" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_res_company__customer_wallet_account_id +#: model:ir.model.fields,field_description:customer_wallet.field_res_config_settings__customer_wallet_account_id +msgid "Customer Wallet Account" +msgstr "Compte comptable du porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_account_payment__customer_wallet_balance +#: model:ir.model.fields,field_description:customer_wallet.field_account_payment_register__customer_wallet_balance +#: model:ir.model.fields,field_description:customer_wallet.field_res_partner__customer_wallet_balance +#: model:ir.model.fields,field_description:customer_wallet.field_res_users__customer_wallet_balance +msgid "Customer Wallet Balance" +msgstr "Solde du porte-monnaie client" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_res_partner_filter +msgid "Customer Wallet Balance Not Zero" +msgstr "Porte-monnaie client non nul" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__customer_wallet_data +#: model:ir.model.fields,field_description:customer_wallet.field_res_partner__customer_wallet_data +#: model:ir.model.fields,field_description:customer_wallet.field_res_users__customer_wallet_data +msgid "Customer Wallet Data" +msgstr "Données du porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_customer_wallet_detail_wizard +msgid "Customer Wallet Detail Wizard" +msgstr "Assistant de détail du porte-monnaie client" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/models/res_partner.py:0 +#, python-format +msgid "Customer Wallet Details" +msgstr "Détails du porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_account_journal__is_customer_wallet_journal +#: model:ir.model.fields,field_description:customer_wallet.field_account_payment__is_customer_wallet_journal +#: model:ir.model.fields,field_description:customer_wallet.field_account_payment_register__is_customer_wallet_journal +msgid "Customer Wallet Journal" +msgstr "Journal de porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_customer_wallet_redistribute_wizard +msgid "Customer Wallet Redistribute Wizard" +msgstr "Assistant de redistribution de porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_customer_wallet_redistribute_wizard_line +msgid "Customer Wallet Redistribute Wizard Line" +msgstr "Ligne d'assistant de redistribution de porte-monnaie client" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard.py:0 +#, python-format +msgid "Customer Wallet Redistribution" +msgstr "Redistribution de porte-monnaie client" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard.py:0 +#, python-format +msgid "Customer Wallet. Receipt from %(partner_name)s" +msgstr "Porte-monnaie client. Reçu par %(partner_name)s" + +#. module: customer_wallet +#: model:ir.actions.act_window,name:customer_wallet.action_res_partner_wallet +#: model:ir.ui.menu,name:customer_wallet.menu_res_partner_wallet +msgid "Customer Wallets" +msgstr "Porte-monnaie clients" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_detail_wizard.py:0 +#, python-format +msgid "Date" +msgstr "Date" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__detail +msgid "Detail" +msgstr "Détail" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_res_partner_tree +msgid "Details" +msgstr "Détails" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__display_name +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__display_name +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_res_partner_filter +msgid "Distinct Customer Wallets" +msgstr "Porte-monnaie clients distincts" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_res_partner__has_customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_res_users__has_customer_wallet +msgid "Has Customer Wallet" +msgstr "A un porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__id +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__id +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__id +msgid "ID" +msgstr "ID" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_res_company__is_enabled_customer_wallet +msgid "Is Customer Wallet Enabled" +msgstr "Porte-monnaie client activé" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_account_journal +msgid "Journal" +msgstr "Journal" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard____last_update +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard____last_update +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__write_uid +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__write_uid +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__write_uid +msgid "Last Updated by" +msgstr "Dernière modification par" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__write_date +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__write_date +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__write_date +msgid "Last Updated on" +msgstr "Dernière modification le" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.res_config_settings_view_form +msgid "Let customers pay from a wallet account" +msgstr "Autoriser les clients à payer avec un porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__line_ids +msgid "Line" +msgstr "Lignes" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_account_journal__minimum_wallet_amount +msgid "Minimum Wallet Amount" +msgstr "Montant minimum du porte-monnaie client" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard_line.py:0 +#, python-format +msgid "Only positive amount is allowed. Incorrect value %(amount)s" +msgstr "Un montant positif est accepté seulement. Valeur incorrecte : %(amount)s" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_detail_wizard__partner_id +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard__partner_id +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__partner_id +msgid "Partner" +msgstr "Partenaire" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_account_payment +msgid "Payments" +msgstr "Paiements" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard.py:0 +#, python-format +msgid "Please set one or many lines." +msgstr "Veuillez définir une ou plusieurs lignes." + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_product_template +msgid "Product" +msgstr "Produit" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_customer_wallet_redistribute_wizard_form +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_res_partner_tree +msgid "Redistribute" +msgstr "Redistribuer" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/models/res_partner.py:0 +#, python-format +msgid "Redistribute Customer Wallet" +msgstr "Redistribuer le porte-monnaie clients" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_partner_form +msgid "Redistribute Wallet" +msgstr "Redistribuer le porte-monnaie client" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_detail_wizard.py:0 +#, python-format +msgid "Reference" +msgstr "Référence" + +#. module: customer_wallet +#: model:ir.model,name:customer_wallet.model_account_payment_register +msgid "Register Payment" +msgstr "Enregistrer un paiement" + +#. module: customer_wallet +#: model:ir.model.fields,help:customer_wallet.field_res_config_settings__customer_wallet_account_id +msgid "The account where all wallet transactions will be recorded" +msgstr "" +"Le compte dans lequel toutes les transactions de porte-monnaie client seront " +"enregistrées" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard.py:0 +#, python-format +msgid "" +"The new balance (%(new_balance)s) is lower than the minimum defined in the " +"journal (%(minimum_amount)s)." +msgstr "Le nouveau solde (%(new_balance)s) est plus bas que le minimum" +" défini dans le journal (%(minimum_amount)s)." + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard.py:0 +#, python-format +msgid "The redistributor customer is included in the list of beneficiaries." +msgstr "Le client redistributeur est dans la liste des bénéficiaires." + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/models/account_payment.py:0 +#, python-format +msgid "" +"There is not enough balance in the customer's wallet to perform this " +"payment. \n" +" - Customer : %(partner)s\n" +" - Customer Wallet : %(balance)s\n" +" - Amount Payment : %(amount)s\n" +" - Minimum Wallet Amount: %(minimum)s" +msgstr "" +"Il n'y a pas assez d'argent sur le porte-monnaie client de ce partenaire, " +"pour valider ce paiement. \n" +" - Client : %(partner)s\n" +" - Solde du porte-monnaie client : %(balance)s\n" +" - Montant du paiement : %(amount)s\n" +" - Montant minimum : %(minimum)s" + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard.py:0 +#, python-format +msgid "There no 'Wallet' journal defined. Please configure one first." +msgstr "Il n'y a pas de journal de porte-monnaie défini. Veuillez en configurer un au préalable." + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_customer_wallet_redistribute_wizard_form +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_res_partner_tree +msgid "Total" +msgstr "Total" + +#. module: customer_wallet +#: model:ir.model.fields,help:customer_wallet.field_account_journal__minimum_wallet_amount +msgid "" +"Usually 0. You can enter a negative value, if you want to accept that the " +"customer wallet is negative. Maybe useful if the sale amount is slightly " +"higher than the wallet amount, to avoid charging the customer a small amount." +msgstr "" +"Habituellement 0. Vous pouvez saisir ici une valeur négative, si vous " +"acceptez que le solde d'un porte-monnaie client soit négatif. Cela peut être " +"utile si le montant d'une vente est légèrement supérieur au solde du porte-" +"monnaie client, pour éviter d'encaisser le client pour une petite somme." + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_partner_form +msgid "Wallet Details" +msgstr "Détails du porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_product_product__is_customer_wallet_product +#: model:ir.model.fields,field_description:customer_wallet.field_product_template__is_customer_wallet_product +#: model:product.template,name:customer_wallet.product_wallet_demo_product_template +msgid "Wallet Product" +msgstr "Produit de porte-monnaie client" + +#. module: customer_wallet +#: model:ir.model.fields,field_description:customer_wallet.field_customer_wallet_redistribute_wizard_line__wizard_id +msgid "Wizard" +msgstr "Assistant" + +#. module: customer_wallet +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_account_payment_form +#: model_terms:ir.ui.view,arch_db:customer_wallet.view_account_payment_register_form +msgid "You can select the customer account journal for this customer." +msgstr "" +"Vous pouvez sélectionner le journal de porte-monnaie client pour ce client." + +#. module: customer_wallet +#. odoo-python +#: code:addons/customer_wallet/wizards/customer_wallet_redistribute_wizard.py:0 +msgid "You cannot select the same beneficiary twice." +msgstr "Vous ne pouvez pas sélectionner deux fois le même bénéficiaire." diff --git a/account_customer_wallet/models/__init__.py b/customer_wallet/models/__init__.py similarity index 100% rename from account_customer_wallet/models/__init__.py rename to customer_wallet/models/__init__.py index 04e9b9cbe..52b48bb72 100644 --- a/account_customer_wallet/models/__init__.py +++ b/customer_wallet/models/__init__.py @@ -2,5 +2,5 @@ from . import account_payment from . import product_template from . import res_company -from . import res_config_settings from . import res_partner +from . import res_config_settings diff --git a/account_customer_wallet/models/account_journal.py b/customer_wallet/models/account_journal.py similarity index 100% rename from account_customer_wallet/models/account_journal.py rename to customer_wallet/models/account_journal.py diff --git a/account_customer_wallet/models/account_payment.py b/customer_wallet/models/account_payment.py similarity index 70% rename from account_customer_wallet/models/account_payment.py rename to customer_wallet/models/account_payment.py index 04ba62334..344657469 100644 --- a/account_customer_wallet/models/account_payment.py +++ b/customer_wallet/models/account_payment.py @@ -23,6 +23,12 @@ def action_post(self): wallet_payments = self.filtered( lambda x: x.journal_id.is_customer_wallet_journal ) + # In some cases, we dont want to check if the minimum amount is reached + # Use Case : we pay with wallet in the Pos, then we change the minimum amount + # then we want to close the Pos Session: + # Closing the pos session should not be blocked. + if self.env.context.get("customer_wallet_do_not_check", False): + return super().action_post() for payment in wallet_payments: if ( @@ -36,18 +42,21 @@ def action_post(self): and (payment.customer_wallet_balance - payment.amount) < payment.journal_id.minimum_wallet_amount ): + _format = payment.currency_id.format raise UserError( _( "There is not enough balance in the customer's wallet" " to perform this payment. \n" " - Customer : %(partner)s\n" " - Customer Wallet : %(balance)s\n" - " - Amount Payment : %(amount)s" + " - Amount Payment : %(amount)s\n" + " - Minimum Wallet Amount: %(minimum)s" ) % { "partner": payment.partner_id.display_name, - "balance": payment.customer_wallet_balance, - "amount": payment.amount, + "balance": _format(payment.customer_wallet_balance), + "amount": _format(payment.amount), + "minimum": _format(payment.journal_id.minimum_wallet_amount), } ) return super().action_post() diff --git a/customer_wallet/models/product_template.py b/customer_wallet/models/product_template.py new file mode 100644 index 000000000..af50c18e2 --- /dev/null +++ b/customer_wallet/models/product_template.py @@ -0,0 +1,23 @@ +# Copyright (C) 2022-Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + is_customer_wallet_product = fields.Boolean( + string="Wallet Product", + help="Check this box if this product is used to credit customer wallets.", + ) + + def _get_product_accounts(self): + if self.is_customer_wallet_product: + company = self.company_id or self.env.company + return { + "income": company.customer_wallet_account_id, + "expense": company.customer_wallet_account_id, + } + return super()._get_product_accounts() diff --git a/account_customer_wallet/models/res_company.py b/customer_wallet/models/res_company.py similarity index 100% rename from account_customer_wallet/models/res_company.py rename to customer_wallet/models/res_company.py diff --git a/account_customer_wallet/models/res_config_settings.py b/customer_wallet/models/res_config_settings.py similarity index 100% rename from account_customer_wallet/models/res_config_settings.py rename to customer_wallet/models/res_config_settings.py diff --git a/customer_wallet/models/res_partner.py b/customer_wallet/models/res_partner.py new file mode 100644 index 000000000..92981d10e --- /dev/null +++ b/customer_wallet/models/res_partner.py @@ -0,0 +1,167 @@ +# Copyright 2022 Coop IT Easy SC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import datetime + +from odoo import _, api, fields, models +from odoo.tools.safe_eval import safe_eval + + +class Partner(models.Model): + _inherit = "res.partner" + + customer_wallet_balance = fields.Monetary( + compute="_compute_customer_wallet", + search="_search_customer_wallet_balance", + recursive=True, + ) + account_move_line_ids = fields.One2many( + comodel_name="account.move.line", + inverse_name="partner_id", + readonly=True, + ) + has_customer_wallet = fields.Boolean(compute="_compute_customer_wallet") + customer_wallet_data = fields.Text(compute="_compute_customer_wallet") + + def get_topmost_parent_id(self): + self.ensure_one() + if not self.parent_id: + return self + return self.parent_id.get_topmost_parent_id() + + def get_all_partners_in_family(self): + self.ensure_one() + return ( + self.with_context(active_test=False) + .search([("id", "child_of", self.get_topmost_parent_id().id)]) + .ids + ) + + def get_wallet_balance_details(self, all_partner_ids, wallet_account_id): + # We use sudo for account.move.line + # to avoid access error, if user is not member of accouting groups + + result = {partner_id: [] for partner_id in all_partner_ids} + domain = [ + ("partner_id", "in", list(all_partner_ids)), + ("parent_state", "=", "posted"), + ("account_id", "=", wallet_account_id.id), + ] + _fields = ["date", "create_date", "balance", "partner_id", "move_id"] + + for line in self.env["account.move.line"].sudo().search_read(domain, _fields): + result[line["partner_id"][0]].append( + { + "model": "account.move.line", + "partner_id": line["partner_id"][0], + "datetime": datetime.datetime( + line["date"].year, line["date"].month, line["date"].day + ), + "create_date": line["create_date"], + "amount": -line["balance"], + "reference": line["move_id"][1], + } + ) + + return result + + def _customer_wallet_depends(self): + return [ + "account_move_line_ids", + "account_move_line_ids.account_id", + "account_move_line_ids.balance", + "account_move_line_ids.parent_state", + "child_ids", + "child_ids.customer_wallet_balance", + "parent_id", + "parent_id.customer_wallet_balance", + ] + + @api.depends(lambda self: self._customer_wallet_depends()) + @api.depends_context("company") + def _compute_customer_wallet(self): + wallet_account_id = self.env.company.customer_wallet_account_id + if not wallet_account_id or not self.ids: + # Always assign a value in a compute method. + self.update( + { + "customer_wallet_balance": 0.0, + "customer_wallet_data": str([]), + "has_customer_wallet": False, + } + ) + return + + all_partner_families = {} + all_partner_ids = set() + + # we split the calculation in two part to optimize it + # because the call of get_all_partners_in_family take time + # and is not necessary for most partners + for partner in self.filtered(lambda x: x.parent_id or x.child_ids): + all_partner_families[partner] = partner.get_all_partners_in_family() + + for partner in self.filtered(lambda x: not x.parent_id and not x.child_ids): + all_partner_families[partner] = [partner.id] + + for val in all_partner_families.values(): + all_partner_ids |= set(val) + + all_totals = self.get_wallet_balance_details(all_partner_ids, wallet_account_id) + + for partner, child_ids in all_partner_families.items(): + lines = [] + for partner_id in child_ids: + lines += all_totals.get(partner_id) + + partner.customer_wallet_balance = sum(line["amount"] for line in lines) + lines.sort(key=lambda x: (x["datetime"], x["create_date"])) + balance = 0 + for line in lines: + balance += line["amount"] + line["balance"] = balance + partner.has_customer_wallet = len(lines) + partner.customer_wallet_data = str(lines) + + def _search_customer_wallet_balance(self, operator, value): + # This is a complete and utter hack. Don't do what I did. + if operator in ("=", "!=", ">", ">=", "<", "<=", "=?", "in", "not in"): + if operator in ("=", "=?"): + operator = "==" + filter_string = "partner.customer_wallet_balance {operator} {value}".format( + operator=operator, value=value + ) + filtered = self.search([]).filtered( + lambda partner: safe_eval( + filter_string, + {"partner": partner}, + ) + ) + if filtered: + return [("id", "in", [partner.id for partner in filtered])] + return [] + else: + # TODO maybe + raise NotImplementedError() + + def action_view_customer_wallet_details(self): + self.ensure_one() + return { + "name": _("Customer Wallet Details"), + "view_mode": "form", + "res_model": "customer.wallet.detail.wizard", + "type": "ir.actions.act_window", + "target": "new", + "context": {"default_partner_id": self.id}, + } + + def action_view_customer_wallet_redistribute(self): + self.ensure_one() + return { + "name": _("Redistribute Customer Wallet"), + "view_mode": "form", + "res_model": "customer.wallet.redistribute.wizard", + "type": "ir.actions.act_window", + "target": "new", + "context": {"default_partner_id": self.id}, + } diff --git a/account_customer_wallet/readme/CONFIGURE.rst b/customer_wallet/readme/CONFIGURE.rst similarity index 60% rename from account_customer_wallet/readme/CONFIGURE.rst rename to customer_wallet/readme/CONFIGURE.rst index 72b20eb09..735907b93 100644 --- a/account_customer_wallet/readme/CONFIGURE.rst +++ b/customer_wallet/readme/CONFIGURE.rst @@ -2,12 +2,18 @@ Setting this up requires a few careful steps: - Make sure your user has access to all accounting features. - Create an account (Customer Wallet) that is a liability. + .. figure:: ../static/description/configure_account_account.png + In France, the account generally used will be "4197" - "Clients – Autres avoirs". - Create a journal (Customer Wallet). Enable the 'Customer Wallet Journal' toggle, set the Bank Account to the previously created account, and in the payment methods (both incoming and outgoing), set the Outstanding Receipts and Outstanding Payments accounts to the previously created account. You may need to toggle the visibility of these fields in the tables. + .. figure:: ../static/description/configure_account_journal.png - In the Invoicing settings, set the Customer Wallet Account to the previously created account. + .. figure:: ../static/description/configure_res_config_settings.png - (Optional) Create a product (Wallet Product), and enable the Wallet Product - toggle. Set the income and expense account to the previously created account. + toggle. The income and expense accounts will be automatically set to the Customer + Wallet Account previously created. + .. figure:: ../static/description/configure_product_template.png diff --git a/account_customer_wallet/readme/CONTRIBUTORS.rst b/customer_wallet/readme/CONTRIBUTORS.rst similarity index 56% rename from account_customer_wallet/readme/CONTRIBUTORS.rst rename to customer_wallet/readme/CONTRIBUTORS.rst index d64451edc..61fd0a661 100644 --- a/account_customer_wallet/readme/CONTRIBUTORS.rst +++ b/customer_wallet/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * `Coop IT Easy SC `_: - * Carmen Bianca Bakker +* `GRAP `_: + * Sylvain LE GAL diff --git a/customer_wallet/readme/DESCRIPTION.rst b/customer_wallet/readme/DESCRIPTION.rst new file mode 100644 index 000000000..acdb50a4e --- /dev/null +++ b/customer_wallet/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +Allow customers to pay using a wallet which is tracked by the company. + +A wallet is a cash advance provided by the customer, +which can be used to make purchases at a later date. diff --git a/account_customer_wallet/readme/HISTORY.rst b/customer_wallet/readme/HISTORY.rst similarity index 100% rename from account_customer_wallet/readme/HISTORY.rst rename to customer_wallet/readme/HISTORY.rst diff --git a/customer_wallet/readme/ROADMAP.rst b/customer_wallet/readme/ROADMAP.rst new file mode 100644 index 000000000..6c61a56ea --- /dev/null +++ b/customer_wallet/readme/ROADMAP.rst @@ -0,0 +1,3 @@ +* Improve demo / test data for accountings items. + See: complete reflection + https://github.com/coopiteasy/addons/pull/397#discussion_r2894692265 \ No newline at end of file diff --git a/customer_wallet/readme/USAGE.rst b/customer_wallet/readme/USAGE.rst new file mode 100644 index 000000000..41c85e153 --- /dev/null +++ b/customer_wallet/readme/USAGE.rst @@ -0,0 +1,31 @@ +**Credit Customer Wallet** + +- Create a new customer invoice +- Select the Customer Wallet Product and put an amount +- Confirm the invoice + + .. figure:: ../static/description/invoice_form_wallet_sale.png + +As a result, the customer has now a credit amount in his customer wallet. + +You can then check Customer Wallet amount on the partner form. + +- Select your customer + +- Open the 'Sale & Purchase' Tab + + .. figure:: ../static/description/partner_form_wallet_amount.png + +You can also see all the Customer Wallets: + +- Click on 'Accounting > Customers > Customer Wallets' + + .. figure:: ../static/description/partner_tree_wallet_amount.png + +**Debit Customer Wallet** + +You can then mark a customer invoice as paid, using the account journal 'Customer Wallet'. + +A message is present in the payment wizard. + +.. figure:: ../static/description/payment_form.png diff --git a/customer_wallet/security/ir.model.access.csv b/customer_wallet/security/ir.model.access.csv new file mode 100644 index 000000000..47502be59 --- /dev/null +++ b/customer_wallet/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +customer_wallet.access_customer_wallet_detail_wizard,access_customer_wallet_detail_wizard,customer_wallet.model_customer_wallet_detail_wizard,base.group_user,1,0,0,0 +customer_wallet.access_customer_wallet_redistribute_wizard,access_customer_wallet_redistribute_wizard,customer_wallet.model_customer_wallet_redistribute_wizard,base.group_user,1,1,1,0 +customer_wallet.access_customer_wallet_redistribute_wizard_line,access_customer_wallet_redistribute_wizard_line,customer_wallet.model_customer_wallet_redistribute_wizard_line,base.group_user,1,1,1,1 diff --git a/customer_wallet/static/description/configure_account_account.png b/customer_wallet/static/description/configure_account_account.png new file mode 100644 index 000000000..76abb9ed4 Binary files /dev/null and b/customer_wallet/static/description/configure_account_account.png differ diff --git a/customer_wallet/static/description/configure_account_journal.png b/customer_wallet/static/description/configure_account_journal.png new file mode 100644 index 000000000..8746e27bd Binary files /dev/null and b/customer_wallet/static/description/configure_account_journal.png differ diff --git a/customer_wallet/static/description/configure_product_template.png b/customer_wallet/static/description/configure_product_template.png new file mode 100644 index 000000000..538934558 Binary files /dev/null and b/customer_wallet/static/description/configure_product_template.png differ diff --git a/customer_wallet/static/description/configure_res_config_settings.png b/customer_wallet/static/description/configure_res_config_settings.png new file mode 100644 index 000000000..85c499b24 Binary files /dev/null and b/customer_wallet/static/description/configure_res_config_settings.png differ diff --git a/customer_wallet/static/description/index.html b/customer_wallet/static/description/index.html new file mode 100644 index 000000000..c2634c7c3 --- /dev/null +++ b/customer_wallet/static/description/index.html @@ -0,0 +1,524 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Customer Wallet

+ +

Beta License: AGPL-3 coopiteasy/addons

+

Allow customers to pay using a wallet which is tracked by the company.

+

A wallet is a cash advance provided by the customer, +which can be used to make purchases at a later date.

+

Table of contents

+ +
+

Configuration

+

Setting this up requires a few careful steps:

+ +
+
+

Usage

+

Credit Customer Wallet

+
    +
  • Create a new customer invoice

    +
  • +
  • Select the Customer Wallet Product and put an amount

    +
  • +
  • Confirm the invoice

    +
    +https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/invoice_form_wallet_sale.png +
    +
  • +
+

As a result, the customer has now a credit amount in his customer wallet.

+

You can then check Customer Wallet amount on the partner form.

+
    +
  • Select your customer

    +
  • +
  • Open the ‘Sale & Purchase’ Tab

    +
    +https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/partner_form_wallet_amount.png +
    +
  • +
+

You can also see all the Customer Wallets:

+
    +
  • Click on ‘Accounting > Customers > Customer Wallets’

    +
    +https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/partner_tree_wallet_amount.png +
    +
  • +
+

Debit Customer Wallet

+

You can then mark a customer invoice as paid, using the account journal ‘Customer Wallet’.

+

A message is present in the payment wizard.

+
+https://raw.githubusercontent.com/coopiteasy/addons/16.0/customer_wallet/static/description/payment_form.png +
+
+
+

Known issues / Roadmap

+ +
+
+

Changelog

+
+

12.0.1.2.0 (2022-07-08)

+

Misc

+ +

12.0.1.1.0 (2022-06-23) +Features

+
    +
  • Make customer_wallet_balance searchable, and add a filter for non-zero +balances. (#235)
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Coop IT Easy SC
  • +
  • GRAP
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

Current maintainers:

+

carmenbianca legalsylvain

+

This module is part of the coopiteasy/addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+
+ + diff --git a/customer_wallet/static/description/invoice_form_wallet_sale.png b/customer_wallet/static/description/invoice_form_wallet_sale.png new file mode 100644 index 000000000..3d9ce6914 Binary files /dev/null and b/customer_wallet/static/description/invoice_form_wallet_sale.png differ diff --git a/customer_wallet/static/description/partner_form_wallet_amount.png b/customer_wallet/static/description/partner_form_wallet_amount.png new file mode 100644 index 000000000..d9627767a Binary files /dev/null and b/customer_wallet/static/description/partner_form_wallet_amount.png differ diff --git a/customer_wallet/static/description/partner_tree_wallet_amount.png b/customer_wallet/static/description/partner_tree_wallet_amount.png new file mode 100644 index 000000000..059bfdd98 Binary files /dev/null and b/customer_wallet/static/description/partner_tree_wallet_amount.png differ diff --git a/customer_wallet/static/description/payment_form.png b/customer_wallet/static/description/payment_form.png new file mode 100644 index 000000000..72f7e4918 Binary files /dev/null and b/customer_wallet/static/description/payment_form.png differ diff --git a/customer_wallet/tests/__init__.py b/customer_wallet/tests/__init__.py new file mode 100644 index 000000000..81a9c83a7 --- /dev/null +++ b/customer_wallet/tests/__init__.py @@ -0,0 +1,5 @@ +from . import common +from . import test_balance +from . import test_search +from . import test_detail_wizard +from . import test_redistribute_wizard diff --git a/account_customer_wallet/tests/common.py b/customer_wallet/tests/common.py similarity index 86% rename from account_customer_wallet/tests/common.py rename to customer_wallet/tests/common.py index fd6e6a064..528f45143 100644 --- a/account_customer_wallet/tests/common.py +++ b/customer_wallet/tests/common.py @@ -1,10 +1,11 @@ # Copyright 2022 Coop IT Easy SC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import Command from odoo.tests.common import TransactionCase -class TestBalance(TransactionCase): +class TestCommon(TransactionCase): @classmethod def setUpClass(cls, *args, **kwargs): super().setUpClass(*args, **kwargs) @@ -24,25 +25,20 @@ def setUpClass(cls, *args, **kwargs): ) cls.sale_product = template.product_variant_id cls.customer_wallet_account = cls.env.ref( - "account_customer_wallet.account_account_customer_wallet_demo" + "customer_wallet.account_account_customer_wallet_demo" ) cls.sale_account = cls.env["account.account"].search( - [ - ( - "account_type", - "=", - "income", - ) - ], + [("account_type", "=", "income")], limit=1, ) cls.customer_wallet_journal = cls.env.ref( - "account_customer_wallet.account_journal_customer_wallet_demo" + "customer_wallet.account_journal_customer_wallet_demo" ) cls.sale_journal = cls.env["account.journal"].search( [("type", "=", "sale")], limit=1 ) cls.payment_method = cls.env.ref("account.account_payment_method_manual_in") + cls.wallet_product = cls.env.ref("customer_wallet.product_wallet_demo") cls.cash_account = cls.env["account.account"].search( [("account_type", "=", "asset_cash")], limit=1 ) @@ -56,19 +52,15 @@ def _create_move(self, debit=0, credit=0, partner=None): { "journal_id": self.customer_wallet_journal.id, "line_ids": [ - ( - 0, - 0, + Command.create( { "debit": debit, "credit": credit, "partner_id": partner.id, "account_id": self.customer_wallet_account.id, - }, + } ), - ( - 0, - 0, + Command.create( { "debit": credit, "credit": debit, @@ -91,9 +83,7 @@ def _create_sale_invoice(self, invoice_type, amount, partner=None): "move_type": invoice_type, "partner_id": partner.id, "line_ids": [ - ( - 0, - 0, + Command.create( { "name": "Invoice line", "quantity": 1, diff --git a/account_customer_wallet/tests/test_balance.py b/customer_wallet/tests/test_balance.py similarity index 98% rename from account_customer_wallet/tests/test_balance.py rename to customer_wallet/tests/test_balance.py index 5ea91beef..bd71e292f 100644 --- a/account_customer_wallet/tests/test_balance.py +++ b/customer_wallet/tests/test_balance.py @@ -3,10 +3,10 @@ from odoo.exceptions import UserError -from .common import TestBalance +from .common import TestCommon -class TestAccountBalance(TestBalance): +class TestBalance(TestCommon): def test_balance_zero(self): """When doing nothing, a partner's balance is zero.""" self.assertEqual(self.partner.customer_wallet_balance, 0) diff --git a/customer_wallet/tests/test_detail_wizard.py b/customer_wallet/tests/test_detail_wizard.py new file mode 100644 index 000000000..0b9965024 --- /dev/null +++ b/customer_wallet/tests/test_detail_wizard.py @@ -0,0 +1,39 @@ +# Copyright 2022 Coop IT Easy SC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + + +from .common import TestCommon + + +class TestDetailWizard(TestCommon): + @classmethod + def setUpClass(cls, *args, **kwargs): + super().setUpClass(*args, **kwargs) + cls.DetailWizard = cls.env["customer.wallet.detail.wizard"] + + def _get_wizard(self): + return self.DetailWizard.create({"partner_id": self.partner.id}) + + def test_detail_wizard_no_move(self): + wizard = self._get_wizard() + self.assertEqual(wizard.customer_wallet_balance, 0.0) + self.assertNotIn("", wizard.detail) + + def test_detail_wizard_one_move(self): + self._create_move(credit=10) + + wizard = self._get_wizard() + self.assertEqual(wizard.customer_wallet_balance, 10.0) + self.assertIn("", wizard.detail) + self.assertIn("10.0", wizard.detail) + + def test_detail_wizard_many_moves(self): + self._create_move(credit=10) + self._create_move(credit=20) + + wizard = self._get_wizard() + self.assertEqual(wizard.customer_wallet_balance, 30.0) + self.assertIn("", wizard.detail) + self.assertIn("10.0", wizard.detail) + self.assertIn("20.0", wizard.detail) + self.assertIn("30.0", wizard.detail) diff --git a/customer_wallet/tests/test_redistribute_wizard.py b/customer_wallet/tests/test_redistribute_wizard.py new file mode 100644 index 000000000..daf54d752 --- /dev/null +++ b/customer_wallet/tests/test_redistribute_wizard.py @@ -0,0 +1,68 @@ +# Copyright 2022 Coop IT Easy SC +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + + +from odoo.exceptions import UserError + +from .common import TestCommon + + +class TestRedistributeWizard(TestCommon): + @classmethod + def setUpClass(cls, *args, **kwargs): + super().setUpClass(*args, **kwargs) + cls.RedistributeWizard = cls.env["customer.wallet.redistribute.wizard"] + cls.RedistributeWizardLine = cls.env["customer.wallet.redistribute.wizard.line"] + cls.other_partner_1 = cls.env["res.partner"].create( + { + "name": "Other Partner 1", + "company_id": cls.partner.company_id.id, + } + ) + cls.other_partner_2 = cls.env["res.partner"].create( + { + "name": "Other Partner 2", + "company_id": cls.partner.company_id.id, + } + ) + + def _redistribute(self, amount, redistribution_configuration): + wizard = self.RedistributeWizard.create({"partner_id": self.partner.id}) + for line in redistribution_configuration: + self.RedistributeWizardLine.create( + {"wizard_id": wizard.id, "partner_id": line[0].id, "amount": line[1]} + ) + wizard.button_redistribute() + + def test_redistribution_wizard_no_transfer(self): + with self.assertRaises(UserError): + self._redistribute(0.0, []) + + with self.assertRaises(UserError): + self._redistribute(999.0, []) + + def test_redistribution_wizard_one_transfer(self): + self._create_move(credit=100) + + self.assertEqual(self.partner.customer_wallet_balance, 100) + self.assertEqual(self.other_partner_1.customer_wallet_balance, 0) + + self._redistribute(30.0, [(self.other_partner_1, 30)]) + + self.assertEqual(self.partner.customer_wallet_balance, 70) + self.assertEqual(self.other_partner_1.customer_wallet_balance, 30) + + def test_redistribution_wizard_many_transfer(self): + self._create_move(credit=1000) + + self.assertEqual(self.partner.customer_wallet_balance, 1000) + self.assertEqual(self.other_partner_1.customer_wallet_balance, 0) + self.assertEqual(self.other_partner_2.customer_wallet_balance, 0) + + self._redistribute( + 600.0, [(self.other_partner_1, 250), (self.other_partner_2, 350)] + ) + + self.assertEqual(self.partner.customer_wallet_balance, 400) + self.assertEqual(self.other_partner_1.customer_wallet_balance, 250) + self.assertEqual(self.other_partner_2.customer_wallet_balance, 350) diff --git a/account_customer_wallet/tests/test_search.py b/customer_wallet/tests/test_search.py similarity index 98% rename from account_customer_wallet/tests/test_search.py rename to customer_wallet/tests/test_search.py index 35db5fe7d..51a73bc03 100644 --- a/account_customer_wallet/tests/test_search.py +++ b/customer_wallet/tests/test_search.py @@ -1,10 +1,10 @@ # Copyright 2022 Coop IT Easy SC # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from .common import TestBalance +from .common import TestCommon -class TestSearch(TestBalance): +class TestSearch(TestCommon): def test_search_balance_all_zero(self): """On a virgin database, all balances are zero.""" all_partners = self.env["res.partner"].search([]) diff --git a/account_customer_wallet/views/account_journal_views.xml b/customer_wallet/views/account_journal_views.xml similarity index 88% rename from account_customer_wallet/views/account_journal_views.xml rename to customer_wallet/views/account_journal_views.xml index eccb69353..db122e5d3 100644 --- a/account_customer_wallet/views/account_journal_views.xml +++ b/customer_wallet/views/account_journal_views.xml @@ -1,7 +1,7 @@ - account_customer_wallet.view_account_journal_form + customer_wallet.view_account_journal_form account.journal diff --git a/account_customer_wallet/views/account_payment_views.xml b/customer_wallet/views/account_payment_views.xml similarity index 66% rename from account_customer_wallet/views/account_payment_views.xml rename to customer_wallet/views/account_payment_views.xml index 979de9858..791d6356f 100644 --- a/account_customer_wallet/views/account_payment_views.xml +++ b/customer_wallet/views/account_payment_views.xml @@ -7,6 +7,15 @@ account.payment + + + - account_customer_wallet.res_config_settings_view_form + customer_wallet.res_config_settings_view_form res.config.settings @@ -13,7 +13,7 @@ expr="//div[@id='pay_invoice_online_setting_container']" position="inside" > -
+