From 88ad25b34fcfb2295e3d51f124b95c5a575e7ad8 Mon Sep 17 00:00:00 2001 From: Nelson V Date: Mon, 19 Jan 2026 17:18:20 -0500 Subject: [PATCH 1/2] [MIGRATION] account_payment_multi_deduction --- account_payment_multi_deduction/README.rst | 126 +++++ account_payment_multi_deduction/__init__.py | 3 + .../__manifest__.py | 19 + .../i18n/account_payment_multi_deduction.pot | 176 +++++++ account_payment_multi_deduction/i18n/es_CO.po | 176 +++++++ .../models/__init__.py | 2 + .../models/account_payment.py | 71 +++ .../pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 4 + .../readme/DESCRIPTION.md | 6 + .../readme/HISTORY.md | 9 + .../readme/USAGE.md | 10 + .../security/ir.model.access.csv | 2 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 475 ++++++++++++++++++ .../tests/__init__.py | 2 + .../tests/test_payment_multi_deduction.py | 336 +++++++++++++ .../wizard/__init__.py | 3 + .../wizard/account_payment_deduction.py | 48 ++ .../wizard/account_payment_register.py | 127 +++++ .../wizard/account_payment_register_views.xml | 61 +++ 21 files changed, 1659 insertions(+) create mode 100644 account_payment_multi_deduction/README.rst create mode 100644 account_payment_multi_deduction/__init__.py create mode 100644 account_payment_multi_deduction/__manifest__.py create mode 100644 account_payment_multi_deduction/i18n/account_payment_multi_deduction.pot create mode 100644 account_payment_multi_deduction/i18n/es_CO.po create mode 100644 account_payment_multi_deduction/models/__init__.py create mode 100644 account_payment_multi_deduction/models/account_payment.py create mode 100644 account_payment_multi_deduction/pyproject.toml create mode 100755 account_payment_multi_deduction/readme/CONTRIBUTORS.md create mode 100755 account_payment_multi_deduction/readme/DESCRIPTION.md create mode 100755 account_payment_multi_deduction/readme/HISTORY.md create mode 100755 account_payment_multi_deduction/readme/USAGE.md create mode 100644 account_payment_multi_deduction/security/ir.model.access.csv create mode 100755 account_payment_multi_deduction/static/description/icon.png create mode 100755 account_payment_multi_deduction/static/description/index.html create mode 100644 account_payment_multi_deduction/tests/__init__.py create mode 100644 account_payment_multi_deduction/tests/test_payment_multi_deduction.py create mode 100644 account_payment_multi_deduction/wizard/__init__.py create mode 100644 account_payment_multi_deduction/wizard/account_payment_deduction.py create mode 100644 account_payment_multi_deduction/wizard/account_payment_register.py create mode 100644 account_payment_multi_deduction/wizard/account_payment_register_views.xml diff --git a/account_payment_multi_deduction/README.rst b/account_payment_multi_deduction/README.rst new file mode 100644 index 00000000000..95ccb1e90c0 --- /dev/null +++ b/account_payment_multi_deduction/README.rst @@ -0,0 +1,126 @@ +======================================== +Payment Register with Multiple Deduction +======================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7e73cf089af47fd6632d12430079775750fdf024624ffd0cf2857c1018a0c519 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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-OCA%2Faccount--payment-lightgray.png?logo=github + :target: https://github.com/OCA/account-payment/tree/18.0/account_payment_multi_deduction + :alt: OCA/account-payment +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-payment-18-0/account-payment-18-0-account_payment_multi_deduction + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extend invoice(s)'s register payment feature, from "Mark +invoice as fully paid" with a single writeoff amount, to "Mark invoice +as fully paid (multi deduct)" which allow multiple deduction amounts. + +**Note:** We use the word "Deduction", as the diff amount can be +anything not only to writeoff. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Select 1 invoice, either on form view or tree view +- Click to Register Payment, a payment wizard will open +- Reduce the amount to pay and payment difference amount will appear +- Choose "Mark invoice as fully paid (multi deduct)", and a new + deduction table will appear +- Add deduction amount, make sure total deduction amount is equal to the + payment difference +- Click validate to finish the payment + +Note: this feature only works for 1 invoice payment + +Changelog +========= + +13.0.1.0.0 (2020-01-27) +----------------------- + +- Migration to version 13 +- Following how Odoo 13 works with deduction, the multiple deduction + feature only works for one invoice at a time. + +12.0.1.0.0 (2019-05-05) +----------------------- + +- Start of the history + +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 +------- + +* Ecosoft + +Contributors +------------ + +- Kitti Upariphutthiphong. (http://ecosoft.co.th) +- Saran Lim. +- Randall Castro. +- Jesús Valdez. + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-kittiu| image:: https://github.com/kittiu.png?size=40px + :target: https://github.com/kittiu + :alt: kittiu + +Current `maintainer `__: + +|maintainer-kittiu| + +This module is part of the `OCA/account-payment `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_multi_deduction/__init__.py b/account_payment_multi_deduction/__init__.py new file mode 100644 index 00000000000..ceeb1a31d80 --- /dev/null +++ b/account_payment_multi_deduction/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +from . import models +from . import wizard diff --git a/account_payment_multi_deduction/__manifest__.py b/account_payment_multi_deduction/__manifest__.py new file mode 100644 index 00000000000..4149821b328 --- /dev/null +++ b/account_payment_multi_deduction/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "Payment Register with Multiple Deduction", + "version": "18.0.1.0.0", + "author": "Ecosoft, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/account-payment", + "category": "Accounting", + "depends": ["account"], + "data": [ + "security/ir.model.access.csv", + "wizard/account_payment_register_views.xml", + ], + "installable": True, + "development_status": "Alpha", + "maintainers": ["kittiu"], +} diff --git a/account_payment_multi_deduction/i18n/account_payment_multi_deduction.pot b/account_payment_multi_deduction/i18n/account_payment_multi_deduction.pot new file mode 100644 index 00000000000..f4fe51470e2 --- /dev/null +++ b/account_payment_multi_deduction/i18n/account_payment_multi_deduction.pot @@ -0,0 +1,176 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_multi_deduction +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-01-19 20:11+0000\n" +"PO-Revision-Date: 2026-01-19 20:11+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_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__account_id +msgid "Account" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__analytic_distribution +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__analytic_distribution +msgid "Analytic Distribution" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__analytic_precision +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__analytic_precision +msgid "Analytic Precision" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__company_id +msgid "Company" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__create_uid +msgid "Created by" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__create_date +msgid "Created on" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__currency_id +msgid "Currency" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__deduct_analytic_distribution +msgid "Deduct Analytic Distribution" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__amount +msgid "Deduction Amount" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__deduction_ids +msgid "Deductions" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__display_name +msgid "Display Name" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__distribution_analytic_account_ids +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__distribution_analytic_account_ids +msgid "Distribution Analytic Account" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__id +msgid "ID" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment__is_multi_deduction +msgid "Is Multi Deduction" +msgstr "" + +#. module: account_payment_multi_deduction +#. odoo-python +#: code:addons/account_payment_multi_deduction/wizard/account_payment_deduction.py:0 +msgid "Keep open" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,help:account_payment_multi_deduction.field_account_payment_deduction__is_open +msgid "Keep this line open" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__name +msgid "Label" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__write_date +msgid "Last Updated on" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields.selection,name:account_payment_multi_deduction.selection__account_payment_register__payment_difference_handling__reconcile_multi_deduct +msgid "Mark invoice as fully paid (multi deduct)" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__is_open +msgid "Open" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model,name:account_payment_multi_deduction.model_account_payment_register +msgid "Pay" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__payment_id +msgid "Payment" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model,name:account_payment_multi_deduction.model_account_payment_deduction +msgid "Payment Deduction" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__payment_difference_handling +msgid "Payment Difference Handling" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model,name:account_payment_multi_deduction.model_account_payment +msgid "Payments" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__deduct_residual +msgid "Remainings" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,help:account_payment_multi_deduction.field_account_payment_register__deduction_ids +msgid "Sum of deduction amount(s) must equal to the payment difference" +msgstr "" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,help:account_payment_multi_deduction.field_account_payment_deduction__currency_id +msgid "The payment's currency." +msgstr "" + +#. module: account_payment_multi_deduction +#. odoo-python +#: code:addons/account_payment_multi_deduction/wizard/account_payment_register.py:0 +msgid "The total deduction should be %s" +msgstr "" + +#. module: account_payment_multi_deduction +#: model_terms:ir.ui.view,arch_db:account_payment_multi_deduction.view_account_payment_register_form +msgid "Total Deduction" +msgstr "" diff --git a/account_payment_multi_deduction/i18n/es_CO.po b/account_payment_multi_deduction/i18n/es_CO.po new file mode 100644 index 00000000000..fd8882ac098 --- /dev/null +++ b/account_payment_multi_deduction/i18n/es_CO.po @@ -0,0 +1,176 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_multi_deduction +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-01-19 20:11+0000\n" +"PO-Revision-Date: 2026-01-19 20:11+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_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__account_id +msgid "Account" +msgstr "Cuenta" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__analytic_distribution +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__analytic_distribution +msgid "Analytic Distribution" +msgstr "Distribución analítica" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__analytic_precision +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__analytic_precision +msgid "Analytic Precision" +msgstr "Precisión analítica" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__company_id +msgid "Company" +msgstr "Compañía" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__currency_id +msgid "Currency" +msgstr "Moneda" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__deduct_analytic_distribution +msgid "Deduct Analytic Distribution" +msgstr "Distribución analítica de deducción" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__amount +msgid "Deduction Amount" +msgstr "Monto de la deducción" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__deduction_ids +msgid "Deductions" +msgstr "Deducciones" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__display_name +msgid "Display Name" +msgstr "Nombre para mostrar" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__distribution_analytic_account_ids +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__distribution_analytic_account_ids +msgid "Distribution Analytic Account" +msgstr "Cuenta analítica de distribución" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__id +msgid "ID" +msgstr "ID" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment__is_multi_deduction +msgid "Is Multi Deduction" +msgstr "Es deducción múltiple" + +#. module: account_payment_multi_deduction +#. odoo-python +#: code:addons/account_payment_multi_deduction/wizard/account_payment_deduction.py:0 +msgid "Keep open" +msgstr "Mantener abierto" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,help:account_payment_multi_deduction.field_account_payment_deduction__is_open +msgid "Keep this line open" +msgstr "Mantener esta línea abierta" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__name +msgid "Label" +msgstr "Etiqueta" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__write_uid +msgid "Last Updated by" +msgstr "Última modificación por" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__write_date +msgid "Last Updated on" +msgstr "Última modificación el" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields.selection,name:account_payment_multi_deduction.selection__account_payment_register__payment_difference_handling__reconcile_multi_deduct +msgid "Mark invoice as fully paid (multi deduct)" +msgstr "Marcar factura como pagada (deducción múltiple)" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__is_open +msgid "Open" +msgstr "Abierto" + +#. module: account_payment_multi_deduction +#: model:ir.model,name:account_payment_multi_deduction.model_account_payment_register +msgid "Pay" +msgstr "Pagar" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_deduction__payment_id +msgid "Payment" +msgstr "Pago" + +#. module: account_payment_multi_deduction +#: model:ir.model,name:account_payment_multi_deduction.model_account_payment_deduction +msgid "Payment Deduction" +msgstr "Deducción de pago" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__payment_difference_handling +msgid "Payment Difference Handling" +msgstr "Manejo de diferencias de pago" + +#. module: account_payment_multi_deduction +#: model:ir.model,name:account_payment_multi_deduction.model_account_payment +msgid "Payments" +msgstr "Pagos" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,field_description:account_payment_multi_deduction.field_account_payment_register__deduct_residual +msgid "Remainings" +msgstr "Saldo restante" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,help:account_payment_multi_deduction.field_account_payment_register__deduction_ids +msgid "Sum of deduction amount(s) must equal to the payment difference" +msgstr "La suma de las deducciones debe ser igual a la diferencia de pago" + +#. module: account_payment_multi_deduction +#: model:ir.model.fields,help:account_payment_multi_deduction.field_account_payment_deduction__currency_id +msgid "The payment's currency." +msgstr "La moneda del pago." + +#. module: account_payment_multi_deduction +#. odoo-python +#: code:addons/account_payment_multi_deduction/wizard/account_payment_register.py:0 +msgid "The total deduction should be %s" +msgstr "La deducción total debe ser %s" + +#. module: account_payment_multi_deduction +#: model_terms:ir.ui.view,arch_db:account_payment_multi_deduction.view_account_payment_register_form +msgid "Total Deduction" +msgstr "Deducción total" diff --git a/account_payment_multi_deduction/models/__init__.py b/account_payment_multi_deduction/models/__init__.py new file mode 100644 index 00000000000..7a5433f2077 --- /dev/null +++ b/account_payment_multi_deduction/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +from . import account_payment diff --git a/account_payment_multi_deduction/models/account_payment.py b/account_payment_multi_deduction/models/account_payment.py new file mode 100644 index 00000000000..a8b3de5824c --- /dev/null +++ b/account_payment_multi_deduction/models/account_payment.py @@ -0,0 +1,71 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import fields, models + + +class AccountPayment(models.Model): + _inherit = "account.payment" + + is_multi_deduction = fields.Boolean() + + def _get_check_key_list(self): + return ["name", "account_id"] + + def _get_update_key_list(self): + return ["analytic_distribution"] + + def _update_vals_writeoff( + self, write_off_line_vals, line_vals_list, check_keys, update_keys + ): + for line_vals in line_vals_list: + if all( + line_vals[check_key] == write_off_line_vals[0][check_key] + for check_key in check_keys + ): + for update_key in update_keys: + line_vals[update_key] = write_off_line_vals[0][update_key] + break + + def _prepare_move_line_default_vals( + self, write_off_line_vals=None, force_balance=None + ): + """Split amount to multi payment deduction + Concept: + * Process by payment difference 'Mark as fully paid' and keep value is paid + * Process by each deduction and keep value is deduction + * Combine all process and return list + """ + self.ensure_one() + line_vals_list = super()._prepare_move_line_default_vals( + write_off_line_vals, + force_balance=force_balance, + ) + # payment difference + if not self.is_multi_deduction and write_off_line_vals: + # update writeoff when edit value in payment + writeoff_lines = self._seek_for_lines()[2] + if not write_off_line_vals[0].get("analytic_distribution", False): + write_off_line_vals[0]["analytic_distribution"] = ( + writeoff_lines.analytic_distribution + ) + # add analytic on line_vals_list + check_keys = self._get_check_key_list() + update_keys = self._get_update_key_list() + self._update_vals_writeoff( + write_off_line_vals, line_vals_list, check_keys, update_keys + ) + return line_vals_list + + def _synchronize_from_moves(self, changed_fields): + if any(rec.is_multi_deduction for rec in self): + self = self.with_context(skip_account_move_synchronization=True) + return super()._synchronize_from_moves(changed_fields) + + def write(self, vals): + """Skip move synchronization when + edit payment with multi deduction + """ + if any(rec.is_multi_deduction for rec in self): + self = self.with_context(skip_account_move_synchronization=True) + return super().write(vals) diff --git a/account_payment_multi_deduction/pyproject.toml b/account_payment_multi_deduction/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/account_payment_multi_deduction/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_payment_multi_deduction/readme/CONTRIBUTORS.md b/account_payment_multi_deduction/readme/CONTRIBUTORS.md new file mode 100755 index 00000000000..c4bbe80db8e --- /dev/null +++ b/account_payment_multi_deduction/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Kitti Upariphutthiphong. \ () +- Saran Lim. \ +- Randall Castro. \ +- Jesús Valdez. \ \ No newline at end of file diff --git a/account_payment_multi_deduction/readme/DESCRIPTION.md b/account_payment_multi_deduction/readme/DESCRIPTION.md new file mode 100755 index 00000000000..2a9208f806f --- /dev/null +++ b/account_payment_multi_deduction/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +This module extend invoice(s)'s register payment feature, from "Mark +invoice as fully paid" with a single writeoff amount, to "Mark invoice +as fully paid (multi deduct)" which allow multiple deduction amounts. + +**Note:** We use the word "Deduction", as the diff amount can be +anything not only to writeoff. diff --git a/account_payment_multi_deduction/readme/HISTORY.md b/account_payment_multi_deduction/readme/HISTORY.md new file mode 100755 index 00000000000..0a07355f6a2 --- /dev/null +++ b/account_payment_multi_deduction/readme/HISTORY.md @@ -0,0 +1,9 @@ +## 13.0.1.0.0 (2020-01-27) + +- Migration to version 13 +- Following how Odoo 13 works with deduction, the multiple deduction + feature only works for one invoice at a time. + +## 12.0.1.0.0 (2019-05-05) + +- Start of the history diff --git a/account_payment_multi_deduction/readme/USAGE.md b/account_payment_multi_deduction/readme/USAGE.md new file mode 100755 index 00000000000..11e29665301 --- /dev/null +++ b/account_payment_multi_deduction/readme/USAGE.md @@ -0,0 +1,10 @@ +- Select 1 invoice, either on form view or tree view +- Click to Register Payment, a payment wizard will open +- Reduce the amount to pay and payment difference amount will appear +- Choose "Mark invoice as fully paid (multi deduct)", and a new + deduction table will appear +- Add deduction amount, make sure total deduction amount is equal to the + payment difference +- Click validate to finish the payment + +Note: this feature only works for 1 invoice payment diff --git a/account_payment_multi_deduction/security/ir.model.access.csv b/account_payment_multi_deduction/security/ir.model.access.csv new file mode 100644 index 00000000000..e13bf12d8b1 --- /dev/null +++ b/account_payment_multi_deduction/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_payment_deduction,account.payment.deduction,model_account_payment_deduction,account.group_account_invoice,1,1,1,1 diff --git a/account_payment_multi_deduction/static/description/icon.png b/account_payment_multi_deduction/static/description/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9 zeKEe+b0{#KWGp$F+tga)0RtI)nhMa-K@JS}2krK~n8vJ=Ngm?R!9G<~RyuU0d?nz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VP=U$qSpY(gQ0)59P1&t@y?5rvg<}E+GB}26NYPp4f2YFQrQtot5mn3wu_qprZ=>Ig-$ zbW26Ws~IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/account_payment_multi_deduction/static/description/index.html b/account_payment_multi_deduction/static/description/index.html new file mode 100755 index 00000000000..91136364f36 --- /dev/null +++ b/account_payment_multi_deduction/static/description/index.html @@ -0,0 +1,475 @@ + + + + + +Payment Register with Multiple Deduction + + + +
+

Payment Register with Multiple Deduction

+ + +

Alpha License: AGPL-3 OCA/account-payment Translate me on Weblate Try me on Runboat

+

This module extend invoice(s)’s register payment feature, from “Mark +invoice as fully paid” with a single writeoff amount, to “Mark invoice +as fully paid (multi deduct)” which allow multiple deduction amounts.

+

Note: We use the word “Deduction”, as the diff amount can be +anything not only to writeoff.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Usage

+
    +
  • Select 1 invoice, either on form view or tree view
  • +
  • Click to Register Payment, a payment wizard will open
  • +
  • Reduce the amount to pay and payment difference amount will appear
  • +
  • Choose “Mark invoice as fully paid (multi deduct)”, and a new +deduction table will appear
  • +
  • Add deduction amount, make sure total deduction amount is equal to the +payment difference
  • +
  • Click validate to finish the payment
  • +
+

Note: this feature only works for 1 invoice payment

+
+
+

Changelog

+
+

13.0.1.0.0 (2020-01-27)

+
    +
  • Migration to version 13
  • +
  • Following how Odoo 13 works with deduction, the multiple deduction +feature only works for one invoice at a time.
  • +
+
+
+

12.0.1.0.0 (2019-05-05)

+
    +
  • Start of the history
  • +
+
+
+
+

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

+
    +
  • Ecosoft
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

kittiu

+

This module is part of the OCA/account-payment project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_payment_multi_deduction/tests/__init__.py b/account_payment_multi_deduction/tests/__init__.py new file mode 100644 index 00000000000..178489c220a --- /dev/null +++ b/account_payment_multi_deduction/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +from . import test_payment_multi_deduction diff --git a/account_payment_multi_deduction/tests/test_payment_multi_deduction.py b/account_payment_multi_deduction/tests/test_payment_multi_deduction.py new file mode 100644 index 00000000000..59e3b7a4375 --- /dev/null +++ b/account_payment_multi_deduction/tests/test_payment_multi_deduction.py @@ -0,0 +1,336 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import Command, fields +from odoo.exceptions import UserError +from odoo.tests import Form +from odoo.tests.common import TransactionCase + + +class TestPaymentMultiDeduction(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.move_line_model = cls.env["account.move.line"] + cls.payment_model = cls.env["account.payment"] + cls.payment_register_model = cls.env["account.payment.register"] + cls.partner = cls.env.ref("base.res_partner_12") + cls.company = cls.env.company + cls.account_receivable = cls.partner.property_account_receivable_id + cls.account_revenue = cls.env["account.account"].search( + [ + ("account_type", "=", "income"), + ("company_ids", "in", cls.company.id), + ], + limit=1, + ) + cls.account_expense = cls.env["account.account"].search( + [ + ("account_type", "=", "expense"), + ("company_ids", "in", cls.company.id), + ], + limit=1, + ) + + # Crear cuenta bancaria para el diario de pagos + cls.bank_account = cls.env["account.account"].create( + { + "name": "Test Bank Account", + "code": "TEST.BANK.001", + "account_type": "asset_cash", + "company_ids": [cls.company.id], + } + ) + + # Crear diario de banco con métodos de pago configurados + cls.bank_journal = cls.env["account.journal"].create( + { + "name": "Test Bank Journal", + "code": "TBANK", + "type": "bank", + "company_id": cls.company.id, + } + ) + + # Configurar métodos de pago con payment_account_id + cls.bank_journal.inbound_payment_method_line_ids.write( + {"payment_account_id": cls.bank_account.id} + ) + cls.bank_journal.outbound_payment_method_line_ids.write( + {"payment_account_id": cls.bank_account.id} + ) + + cls.cust_invoice = cls.env["account.move"].create( + { + "name": "Test Customer Invoice", + "move_type": "out_invoice", + "journal_id": cls.env["account.journal"] + .search( + [("type", "=", "sale"), ("company_id", "=", cls.company.id)], + limit=1, + ) + .id, + "partner_id": cls.env.ref("base.res_partner_12").id, + "invoice_line_ids": [ + Command.create( + { + "product_id": cls.env.ref("product.product_product_3").id, + "quantity": 1.0, + "account_id": cls.account_revenue.id, + "name": "[PCSC234] PC Assemble SC234", + "price_unit": 450.00, + "tax_ids": False, + }, + ) + ], + } + ) + + # New currency, 2X lower + cls.company_currency = cls.cust_invoice.currency_id + cls.currency_2x = cls.env["res.currency"].create( + { + "name": "2X", # Foreign currency, 2 time + "symbol": "X", + "rate_ids": [ + ( + 0, + 0, + { + "name": fields.Date.today(), + "company_rate": cls.company_currency.rate * 2, + }, + ) + ], + } + ) + + def test_one_invoice_payment(self): + """Validate 1 invoice and make payment with 2 deduction""" + self.cust_invoice.action_post() # total amount 450.0 + ctx = { + "active_ids": [self.cust_invoice.id], + "active_id": self.cust_invoice.id, + "active_model": "account.move", + } + with self.assertRaises(UserError): # Deduct only 20.0, throw error + with Form( + self.payment_register_model.with_context(**ctx), + ) as f: + f.journal_id = self.bank_journal + f.amount = 400.0 + f.payment_difference_handling = "reconcile_multi_deduct" + with f.deduction_ids.new() as f2: + f2.account_id = self.account_expense + f2.name = "Expense 1" + f2.amount = 20.0 + f.save() + with Form( + self.payment_register_model.with_context(**ctx), + ) as f: + f.journal_id = self.bank_journal + f.amount = 400.0 # Reduce to 400.0, and mark fully paid (multi) + f.payment_difference_handling = "reconcile_multi_deduct" + with f.deduction_ids.new() as f2: + f2.account_id = self.account_expense + f2.name = "Expense 1" + f2.amount = 20.0 + with f.deduction_ids.new() as f2: + f2.account_id = self.account_expense + f2.name = "Expense 2" + f2.amount = 30.0 + + payment_register = f.save() + payment_id = payment_register._create_payments() + payment = self.payment_model.browse(payment_id.id) + self.assertEqual(payment.state, "paid") + + move_lines = self.move_line_model.search([("payment_id", "=", payment.id)]) + bank_account = self.bank_account + self.env.cr.flush() + self.cust_invoice._compute_payment_state() + self.assertEqual(self.cust_invoice.payment_state, "paid") + self.assertRecordValues( + move_lines, + [ + { + "account_id": bank_account.id, + "name": "Manual Payment: Test Customer Invoice", + "debit": 400.0, + "credit": 0.0, + }, + { + "account_id": self.account_receivable.id, + "name": "Manual Payment: Test Customer Invoice", + "debit": 0.0, + "credit": 450.0, + }, + { + "account_id": self.account_expense.id, + "name": "Expense 1", + "debit": 20.0, + "credit": 0.0, + }, + { + "account_id": self.account_expense.id, + "name": "Expense 2", + "debit": 30.0, + "credit": 0.0, + }, + ], + ) + + def test_one_invoice_payment_foreign_currency(self): + """Validate 1 invoice and make payment with 2 deduction""" + self.cust_invoice.action_post() # total amount 450.0 + ctx = { + "active_ids": [self.cust_invoice.id], + "active_id": self.cust_invoice.id, + "active_model": "account.move", + } + with Form( + self.payment_register_model.with_context(**ctx), + ) as f: + f.journal_id = self.bank_journal + f.currency_id = self.currency_2x + f.amount = 800.0 # 400 -> 800 as we use currency 2x + f.payment_difference_handling = "reconcile_multi_deduct" + with f.deduction_ids.new() as f2: + f2.account_id = self.account_expense + f2.name = "Expense 1" + f2.amount = 40.0 # 20 -> 40 + with f.deduction_ids.new() as f2: + f2.account_id = self.account_expense + f2.name = "Expense 2" + f2.amount = 60.0 # 60 -> 80 + + payment_register = f.save() + payment_id = payment_register._create_payments() + payment = self.payment_model.browse(payment_id.id) + self.assertEqual(payment.state, "paid") + + move_lines = self.move_line_model.search([("payment_id", "=", payment.id)]) + bank_account = self.bank_account + self.env.cr.flush() + self.cust_invoice._compute_payment_state() + self.assertEqual(self.cust_invoice.payment_state, "paid") + self.assertRecordValues( + move_lines, + [ + { + "account_id": bank_account.id, + "name": "Manual Payment: Test Customer Invoice", + "debit": 400.0, + "credit": 0.0, + "amount_currency": 800.0, + "currency_id": self.currency_2x.id, + }, + { + "account_id": self.account_receivable.id, + "name": "Manual Payment: Test Customer Invoice", + "debit": 0.0, + "credit": 450.0, + "amount_currency": -900.0, + "currency_id": self.currency_2x.id, + }, + { + "account_id": self.account_expense.id, + "name": "Expense 1", + "debit": 20.0, + "credit": 0.0, + "amount_currency": 40.0, + "currency_id": self.currency_2x.id, + }, + { + "account_id": self.account_expense.id, + "name": "Expense 2", + "debit": 30.0, + "credit": 0.0, + "amount_currency": 60.0, + "currency_id": self.currency_2x.id, + }, + ], + ) + + def test_one_invoice_payment_with_keep_open(self): + """Validate 1 invoice and make payment with 2 deduction, + one as normal deduct and another as keep open""" + self.cust_invoice.action_post() # total amount 450.0 + ctx = { + "active_ids": [self.cust_invoice.id], + "active_id": self.cust_invoice.id, + "active_model": "account.move", + } + with Form( + self.payment_register_model.with_context(**ctx), + ) as f: + f.journal_id = self.bank_journal + f.amount = 400.0 # Reduce to 400.0, and mark fully paid (multi) + f.payment_difference_handling = "reconcile_multi_deduct" + with f.deduction_ids.new() as f2: + f2.account_id = self.account_expense + f2.name = "Expense 1" + f2.amount = 20.0 + with f.deduction_ids.new() as f2: # Keep Open + f2.is_open = True + f2.amount = 30.0 + payment_register = f.save() + payment_id = payment_register._create_payments() + payment = self.payment_model.browse(payment_id.id) + self.assertEqual(payment.state, "paid") + move_lines = self.move_line_model.search([("payment_id", "=", payment.id)]) + bank_account = self.bank_account + self.assertEqual(self.cust_invoice.payment_state, "partial") + self.assertEqual(self.cust_invoice.amount_residual, 30) + self.assertRecordValues( + move_lines, + [ + { + "account_id": bank_account.id, + "name": "Manual Payment: Test Customer Invoice", + "debit": 400.0, + "credit": 0.0, + }, + { + "account_id": self.account_receivable.id, + "name": "Manual Payment: Test Customer Invoice", + "debit": 0.0, + "credit": 420.0, + }, + { + "account_id": self.account_expense.id, + "name": "Expense 1", + "debit": 20.0, + "credit": 0.0, + }, + ], + ) + + def test_invoice_payment_fully_paid(self): + """Validate 1 invoice and make payment with 1 deduction""" + self.cust_invoice.action_post() # total amount 450.0 + ctx = { + "active_ids": [self.cust_invoice.id], + "active_id": self.cust_invoice.id, + "active_model": "account.move", + } + with Form( + self.payment_register_model.with_context(**ctx), + ) as f: + f.journal_id = self.bank_journal + f.amount = 400.0 # Reduce to 400.0, and mark fully paid (multi) + f.payment_difference_handling = "reconcile" + f.writeoff_account_id = self.account_expense + payment_register = f.save() + payment_id = payment_register._create_payments() + payment = self.payment_model.browse(payment_id.id) + self.assertEqual(payment.state, "paid") + + move_lines = self.move_line_model.search( + [ + ("payment_id", "=", payment.id), + ("account_id", "=", self.account_expense.id), + ] + ) + self.assertEqual(len(move_lines), 1) diff --git a/account_payment_multi_deduction/wizard/__init__.py b/account_payment_multi_deduction/wizard/__init__.py new file mode 100644 index 00000000000..968e95711ac --- /dev/null +++ b/account_payment_multi_deduction/wizard/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +from . import account_payment_deduction +from . import account_payment_register diff --git a/account_payment_multi_deduction/wizard/account_payment_deduction.py b/account_payment_multi_deduction/wizard/account_payment_deduction.py new file mode 100644 index 00000000000..ad628609211 --- /dev/null +++ b/account_payment_multi_deduction/wizard/account_payment_deduction.py @@ -0,0 +1,48 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import _, api, fields, models + + +class AccountPaymentDeduction(models.TransientModel): + _name = "account.payment.deduction" + _inherit = "analytic.mixin" + _description = "Payment Deduction" + + payment_id = fields.Many2one( + comodel_name="account.payment.register", + readonly=True, + ondelete="cascade", + ) + company_id = fields.Many2one( + comodel_name="res.company", + related="payment_id.company_id", + store=True, + readonly=True, + ) + currency_id = fields.Many2one( + comodel_name="res.currency", + related="payment_id.currency_id", + readonly=True, + ) + account_id = fields.Many2one( + comodel_name="account.account", + domain=[("deprecated", "=", False)], + required=False, + ) + is_open = fields.Boolean(string="Open", help="Keep this line open") + amount = fields.Monetary(string="Deduction Amount", required=True) + name = fields.Char(string="Label", required=True) + + @api.onchange("is_open") + def _onchange_open(self): + if self.is_open: + self.account_id = False + self.name = _("Keep open") + else: + self.name = False + + @api.onchange("account_id") + def _onchange_account_id(self): + if self.account_id: + self.is_open = False diff --git a/account_payment_multi_deduction/wizard/account_payment_register.py b/account_payment_multi_deduction/wizard/account_payment_register.py new file mode 100644 index 00000000000..13dfc615e27 --- /dev/null +++ b/account_payment_multi_deduction/wizard/account_payment_register.py @@ -0,0 +1,127 @@ +# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import _, api, fields, models +from odoo.exceptions import UserError +from odoo.tools import float_compare + + +class AccountPaymentRegister(models.TransientModel): + _name = "account.payment.register" + _inherit = ["account.payment.register", "analytic.mixin"] + + payment_difference_handling = fields.Selection( + selection_add=[ + ("reconcile_multi_deduct", "Mark invoice as fully paid (multi deduct)") + ], + ondelete={"reconcile_multi_deduct": "cascade"}, + ) + deduct_residual = fields.Monetary( + string="Remainings", compute="_compute_deduct_residual" + ) + deduction_ids = fields.One2many( + comodel_name="account.payment.deduction", + inverse_name="payment_id", + string="Deductions", + copy=False, + help="Sum of deduction amount(s) must equal to the payment difference", + ) + deduct_analytic_distribution = fields.Json() + + def _update_vals_deduction(self, moves): + move_lines = moves.mapped("line_ids") + analytic = {} + [ + analytic.update(item) + for item in move_lines.mapped("analytic_distribution") + if item + ] + self.analytic_distribution = analytic + + def _update_vals_multi_deduction(self, moves): + move_lines = moves.mapped("line_ids") + analytic = {} + [ + analytic.update(item) + for item in move_lines.mapped("analytic_distribution") + if item + ] + self.deduct_analytic_distribution = analytic + + @api.onchange("payment_difference", "payment_difference_handling") + def _onchange_default_deduction(self): + active_ids = self.env.context.get("active_ids", []) + moves = self.env["account.move"].browse(active_ids).exists() + if self.payment_difference_handling == "reconcile": + self._update_vals_deduction(moves) + if self.payment_difference_handling == "reconcile_multi_deduct": + self._update_vals_multi_deduction(moves) + + @api.constrains("deduction_ids", "payment_difference_handling") + def _check_deduction_amount(self): + prec_digits = self.company_id.currency_id.decimal_places + for rec in self: + if rec.payment_difference_handling == "reconcile_multi_deduct": + if ( + float_compare( + rec.payment_difference, + sum(rec.deduction_ids.mapped("amount")), + precision_digits=prec_digits, + ) + != 0 + ): + raise UserError( + _("The total deduction should be %s") % rec.payment_difference + ) + + @api.depends("payment_difference", "deduction_ids") + def _compute_deduct_residual(self): + for rec in self: + rec.deduct_residual = rec.payment_difference - sum( + rec.deduction_ids.mapped("amount") + ) + + def _create_payment_vals_from_wizard(self, batch_result): + payment_vals = super()._create_payment_vals_from_wizard(batch_result) + # payment difference + if ( + not self.currency_id.is_zero(self.payment_difference) + and self.payment_difference_handling == "reconcile" + ): + payment_vals["write_off_line_vals"][0]["analytic_distribution"] = ( + self.analytic_distribution + ) + # multi deduction + elif ( + self.payment_difference + and self.payment_difference_handling == "reconcile_multi_deduct" + ): + payment_vals["write_off_line_vals"] = [ + self._prepare_deduct_move_line(deduct) + for deduct in self.deduction_ids.filtered(lambda line: not line.is_open) + ] + payment_vals["is_multi_deduction"] = True + return payment_vals + + def _prepare_deduct_move_line(self, deduct): + conversion_rate = self.env["res.currency"]._get_conversion_rate( + self.currency_id, + self.company_id.currency_id, + self.company_id, + self.payment_date, + ) + write_off_amount_currency = ( + deduct.amount if self.payment_type == "inbound" else -deduct.amount + ) + write_off_balance = self.company_id.currency_id.round( + write_off_amount_currency * conversion_rate + ) + return { + "name": deduct.name, + "account_id": deduct.account_id.id, + "partner_id": self.partner_id.id, + "currency_id": self.currency_id.id, + "amount_currency": write_off_amount_currency, + "balance": write_off_balance, + "analytic_distribution": deduct.analytic_distribution, + } diff --git a/account_payment_multi_deduction/wizard/account_payment_register_views.xml b/account_payment_multi_deduction/wizard/account_payment_register_views.xml new file mode 100644 index 00000000000..22d2ddfb4b7 --- /dev/null +++ b/account_payment_multi_deduction/wizard/account_payment_register_views.xml @@ -0,0 +1,61 @@ + + + account.payment.register.form + account.payment.register + + + +
+
+
+ + + hide_writeoff_section or payment_difference_handling != 'reconcile' + + + + + + + + + + + + + + + + + + + +
+
+
From bebca8393b797c3fc2d4df80d9c0c2f30c09f9f8 Mon Sep 17 00:00:00 2001 From: Nelson V Date: Mon, 19 Jan 2026 17:44:17 -0500 Subject: [PATCH 2/2] [MIGRATION] : account_payment_multi_deduction --- .../readme/CONTRIBUTORS.md | 0 .../readme/DESCRIPTION.md | 0 account_payment_multi_deduction/readme/HISTORY.md | 0 account_payment_multi_deduction/readme/USAGE.md | 0 .../static/description/icon.png | Bin .../static/description/index.html | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 account_payment_multi_deduction/readme/CONTRIBUTORS.md mode change 100755 => 100644 account_payment_multi_deduction/readme/DESCRIPTION.md mode change 100755 => 100644 account_payment_multi_deduction/readme/HISTORY.md mode change 100755 => 100644 account_payment_multi_deduction/readme/USAGE.md mode change 100755 => 100644 account_payment_multi_deduction/static/description/icon.png mode change 100755 => 100644 account_payment_multi_deduction/static/description/index.html diff --git a/account_payment_multi_deduction/readme/CONTRIBUTORS.md b/account_payment_multi_deduction/readme/CONTRIBUTORS.md old mode 100755 new mode 100644 diff --git a/account_payment_multi_deduction/readme/DESCRIPTION.md b/account_payment_multi_deduction/readme/DESCRIPTION.md old mode 100755 new mode 100644 diff --git a/account_payment_multi_deduction/readme/HISTORY.md b/account_payment_multi_deduction/readme/HISTORY.md old mode 100755 new mode 100644 diff --git a/account_payment_multi_deduction/readme/USAGE.md b/account_payment_multi_deduction/readme/USAGE.md old mode 100755 new mode 100644 diff --git a/account_payment_multi_deduction/static/description/icon.png b/account_payment_multi_deduction/static/description/icon.png old mode 100755 new mode 100644 diff --git a/account_payment_multi_deduction/static/description/index.html b/account_payment_multi_deduction/static/description/index.html old mode 100755 new mode 100644