diff --git a/account_payment_promissory_note/README.rst b/account_payment_promissory_note/README.rst index 32ff129cc17..f34a1d4578b 100644 --- a/account_payment_promissory_note/README.rst +++ b/account_payment_promissory_note/README.rst @@ -7,7 +7,7 @@ Account Payment Promissory Note !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:9206847fae734ca79625f4592216c01acbf14ca65738515bdc84f490f22b752e + !! source digest: sha256:5660a9983f61c7d29b410daaa0c153537fb8de4b3ba3e5260b0a7ebffedd9652 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -17,13 +17,13 @@ Account Payment Promissory Note :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/13.0/account_payment_promissory_note + :target: https://github.com/OCA/account-payment/tree/14.0/account_payment_promissory_note :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-13-0/account-payment-13-0-account_payment_promissory_note + :target: https://translation.odoo-community.org/projects/account-payment-14-0/account-payment-14-0-account_payment_promissory_note :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=13.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=14.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -50,7 +50,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -70,6 +70,7 @@ Contributors * Sergio Teruel * Alexandre Díaz * Carlos Roca + * César A. Sánchez Maintainers ~~~~~~~~~~~ @@ -84,6 +85,6 @@ 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. -This module is part of the `OCA/account-payment `_ project on GitHub. +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_promissory_note/__manifest__.py b/account_payment_promissory_note/__manifest__.py index e4c9743f5c1..28cbb75bbee 100644 --- a/account_payment_promissory_note/__manifest__.py +++ b/account_payment_promissory_note/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Account Payment Promissory Note", - "version": "13.0.1.1.1", + "version": "14.0.1.0.0", "license": "AGPL-3", "author": "Tecnativa," "Odoo Community Association (OCA)", "category": "Invoicing Management", diff --git a/account_payment_promissory_note/i18n/account_payment_promissory_note.pot b/account_payment_promissory_note/i18n/account_payment_promissory_note.pot index d700cdcfc75..ebd33e64091 100644 --- a/account_payment_promissory_note/i18n/account_payment_promissory_note.pot +++ b/account_payment_promissory_note/i18n/account_payment_promissory_note.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -21,11 +21,6 @@ msgid "" " " msgstr "" -#. module: account_payment_promissory_note -#: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_promissory_note_mixin__display_name -msgid "Display Name" -msgstr "" - #. module: account_payment_promissory_note #: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_payment__date_due #: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_payment_register__date_due @@ -33,16 +28,6 @@ msgstr "" msgid "Due Date" msgstr "" -#. module: account_payment_promissory_note -#: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_promissory_note_mixin__id -msgid "ID" -msgstr "" - -#. module: account_payment_promissory_note -#: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_promissory_note_mixin____last_update -msgid "Last Modified on" -msgstr "" - #. module: account_payment_promissory_note #: model:ir.model,name:account_payment_promissory_note.model_account_payment msgid "Payments" diff --git a/account_payment_promissory_note/i18n/es.po b/account_payment_promissory_note/i18n/es.po index 0cb09b00b9a..6e5465de301 100644 --- a/account_payment_promissory_note/i18n/es.po +++ b/account_payment_promissory_note/i18n/es.po @@ -7,15 +7,15 @@ msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-18 14:51+0000\n" -"PO-Revision-Date: 2020-11-18 15:55+0100\n" -"Last-Translator: Carlos \n" +"PO-Revision-Date: 2023-09-21 16:38+0000\n" +"Last-Translator: Ivorra78 \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 2.0.6\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" #. module: account_payment_promissory_note #: model_terms:ir.ui.view,arch_db:account_payment_promissory_note.view_account_payment_form_multi @@ -33,11 +33,6 @@ msgstr "" "cada agrupación de facturas de un partner.\n" " " -#. module: account_payment_promissory_note -#: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_promissory_note_mixin__display_name -msgid "Display Name" -msgstr "Mostrar Nombre" - #. module: account_payment_promissory_note #: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_payment__date_due #: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_payment_register__date_due @@ -45,16 +40,6 @@ msgstr "Mostrar Nombre" msgid "Due Date" msgstr "Fecha de Vencimiento" -#. module: account_payment_promissory_note -#: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_promissory_note_mixin__id -msgid "ID" -msgstr "ID" - -#. module: account_payment_promissory_note -#: model:ir.model.fields,field_description:account_payment_promissory_note.field_account_promissory_note_mixin____last_update -msgid "Last Modified on" -msgstr "Última modificación en" - #. module: account_payment_promissory_note #: model:ir.model,name:account_payment_promissory_note.model_account_payment msgid "Payments" @@ -78,6 +63,15 @@ msgstr "" msgid "Register Payment" msgstr "Registrar pago" +#~ msgid "Display Name" +#~ msgstr "Mostrar Nombre" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Última modificación en" + #~ msgid "" #~ "Contains the logic shared between models which allows to register payments" #~ msgstr "" diff --git a/account_payment_promissory_note/models/account_abstract_payment.py b/account_payment_promissory_note/models/account_abstract_payment.py index 1a56d885ce6..60d909d1785 100644 --- a/account_payment_promissory_note/models/account_abstract_payment.py +++ b/account_payment_promissory_note/models/account_abstract_payment.py @@ -9,8 +9,10 @@ class AccountAbstractPayment(models.AbstractModel): _name = "account.promissory.note.mixin" _description = "Promissory Note Mixin" - promissory_note = fields.Boolean(string="Promissory Note",) - date_due = fields.Date(string="Due Date",) + promissory_note = fields.Boolean() + date_due = fields.Date( + string="Due Date", + ) @api.onchange("promissory_note") def _onchange_promissory_note(self): diff --git a/account_payment_promissory_note/models/account_payment.py b/account_payment_promissory_note/models/account_payment.py index 6bbf3d198de..0e6bbfd4750 100644 --- a/account_payment_promissory_note/models/account_payment.py +++ b/account_payment_promissory_note/models/account_payment.py @@ -10,9 +10,13 @@ class AccountPayment(models.Model): _inherit = ["account.payment", "account.promissory.note.mixin"] promissory_note = fields.Boolean( - readonly=True, states={"draft": [("readonly", False)]}, + readonly=True, + states={"draft": [("readonly", False)]}, + ) + date_due = fields.Date( + readonly=True, + states={"draft": [("readonly", False)]}, ) - date_due = fields.Date(readonly=True, states={"draft": [("readonly", False)]},) def _prepare_payment_moves(self): res = super()._prepare_payment_moves() @@ -24,9 +28,21 @@ def _prepare_payment_moves(self): @api.onchange("promissory_note") def _onchange_promissory_note(self): - super()._onchange_promissory_note() + result = super()._onchange_promissory_note() if not self.date_due and self.promissory_note: - invoices = self.invoice_ids + invoices = self.reconciled_invoice_ids same_partner = len(invoices.mapped("partner_id")) == 1 if invoices and same_partner: self.date_due = max(invoices.mapped("invoice_date_due")) + return result + + def write(self, vals): + for payment in self: + if "promissory_note" in vals: + if not vals["promissory_note"]: + payment.line_ids.date_maturity = vals.get("date") or payment.date + elif "date_due" in vals: + payment.line_ids.date_maturity = vals["date_due"] + elif payment.promissory_note and "date_due" in vals: + payment.line_ids.date_maturity = vals["date_due"] + return super().write(vals) diff --git a/account_payment_promissory_note/readme/CONTRIBUTORS.rst b/account_payment_promissory_note/readme/CONTRIBUTORS.rst index 36e69ea6e22..fad476b26c1 100644 --- a/account_payment_promissory_note/readme/CONTRIBUTORS.rst +++ b/account_payment_promissory_note/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * Sergio Teruel * Alexandre Díaz * Carlos Roca + * César A. Sánchez diff --git a/account_payment_promissory_note/static/description/index.html b/account_payment_promissory_note/static/description/index.html index 23de50b8391..11e6f92de51 100644 --- a/account_payment_promissory_note/static/description/index.html +++ b/account_payment_promissory_note/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -367,9 +367,9 @@

Account Payment Promissory Note

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:9206847fae734ca79625f4592216c01acbf14ca65738515bdc84f490f22b752e +!! source digest: sha256:5660a9983f61c7d29b410daaa0c153537fb8de4b3ba3e5260b0a7ebffedd9652 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module allows you to set a date due in a payment, as promissory notes require.

Table of contents

@@ -399,7 +399,7 @@

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.

+feedback.

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

@@ -417,6 +417,7 @@

Contributors

  • Sergio Teruel
  • Alexandre Díaz
  • Carlos Roca
  • +
  • César A. Sánchez
  • @@ -424,11 +425,13 @@

    Contributors

    Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +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.

    -

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

    +

    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_promissory_note/tests/test_account_payment_promissory_note.py b/account_payment_promissory_note/tests/test_account_payment_promissory_note.py index 7c082b9e181..783bc5d807c 100644 --- a/account_payment_promissory_note/tests/test_account_payment_promissory_note.py +++ b/account_payment_promissory_note/tests/test_account_payment_promissory_note.py @@ -2,13 +2,18 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). import datetime -from odoo.tests import Form +from odoo.tests import Form, tagged from odoo.tests.common import TransactionCase +@tagged("-at_install", "post_install") class TestAccountPaymentPromissoryNote(TransactionCase): def setUp(self): super().setUp() + self.company = self.env.user.company_id + self.journal_id = self.env["account.journal"].search( + [("company_id", "=", self.company.id), ("type", "=", "cash")], limit=1 + ) self.payment_method = self.env["account.payment.method"].create( {"name": "Test_MTH", "code": "TST", "payment_type": "inbound"} ) @@ -20,7 +25,7 @@ def setUp(self): "partner_id": partner.id, "invoice_date": "2020-09-14", "invoice_date_due": "2020-09-23", - "type": "out_invoice", + "move_type": "out_invoice", "invoice_line_ids": [(0, 0, {"name": "Test", "price_unit": 20})], } ) @@ -31,53 +36,49 @@ def setUp(self): "partner_id": partner.id, "invoice_date": "2020-09-14", "invoice_date_due": "2020-09-22", - "type": "out_invoice", + "move_type": "out_invoice", "invoice_line_ids": [(0, 0, {"name": "Test", "price_unit": 20})], } ) self.invoice_2.action_post() - self.payment_1 = self.env["account.payment"].create( - { - "payment_type": "inbound", - "payment_method_id": self.payment_method.id, - "amount": 50.00, - "journal_id": self.env["account.journal"] - .search([("type", "=", "sale")], limit=1) - .id, - } - ) - self.payment_2 = self.env["account.payment"].create( + + def test_1_onchange_promissory_note_without_invoices(self): + payment = self.env["account.payment"].create( { - "invoice_ids": [(4, self.invoice_1.id), (4, self.invoice_2.id)], "payment_type": "inbound", "payment_method_id": self.payment_method.id, "amount": 50.00, - "journal_id": self.env["account.journal"] - .search([("type", "=", "sale")], limit=1) - .id, + "journal_id": self.journal_id.id, } ) - - def test_1_onchange_promissory_note_without_invoices(self): - self.payment_1.date_due = "2020-09-21" - self.payment_1._onchange_promissory_note() - self.assertFalse(self.payment_1.date_due) - self.payment_1.promissory_note = True - self.payment_1.date_due = "2020-09-21" - self.payment_1._onchange_promissory_note() + payment.date_due = "2020-09-21" + payment._onchange_promissory_note() + self.assertFalse(payment.date_due) + payment.promissory_note = True + payment.date_due = "2020-09-21" + payment._onchange_promissory_note() self.assertEqual( - self.payment_1.date_due, + payment.date_due, datetime.datetime.strptime("2020-09-21", "%Y-%m-%d").date(), ) def test_2_onchange_promissory_note_with_invoices(self): - self.payment_2.date_due = "2020-09-21" - self.payment_2._onchange_promissory_note() - self.assertFalse(self.payment_2.date_due) - self.payment_2.promissory_note = True - self.payment_2._onchange_promissory_note() + wiz_form = Form( + self.env["account.payment.register"].with_context( + active_model="account.move", + active_ids=[self.invoice_1.id, self.invoice_2.id], + ) + ) + wiz_form.group_payment = True + wiz = wiz_form.save() + payment = wiz._create_payments() + payment.date_due = "2020-09-21" + payment._onchange_promissory_note() + self.assertFalse(payment.date_due) + payment.promissory_note = True + payment._onchange_promissory_note() self.assertEqual( - self.payment_2.date_due, + payment.date_due, datetime.datetime.strptime("2020-09-23", "%Y-%m-%d").date(), ) @@ -88,12 +89,10 @@ def test_3_due_date_propagation(self): active_ids=[self.invoice_1.id, self.invoice_2.id], ) ) - wiz_form.payment_method_id = self.payment_method wiz_form.promissory_note = True wiz_form.group_payment = True wiz_form.date_due = datetime.datetime.strptime("2020-09-23", "%Y-%m-%d").date() wiz = wiz_form.save() - action_vals = wiz.create_payments() - payment = self.env["account.payment"].search(action_vals["domain"]) - for line in payment.move_line_ids: - self.assertEquals(line.date_maturity, payment.date_due) + payment = wiz._create_payments() + for line in payment.line_ids: + self.assertEqual(line.date_maturity, payment.date_due) diff --git a/account_payment_promissory_note/views/account_payment_invoice_view.xml b/account_payment_promissory_note/views/account_payment_invoice_view.xml index f05cc97e411..6240b384570 100644 --- a/account_payment_promissory_note/views/account_payment_invoice_view.xml +++ b/account_payment_promissory_note/views/account_payment_invoice_view.xml @@ -2,9 +2,9 @@ account.payment.register - + - + Set date due to all payments or empty to select last date due of each partner invoices group - + diff --git a/account_payment_promissory_note/views/account_payment_view.xml b/account_payment_promissory_note/views/account_payment_view.xml index 75663758ff4..de13bf2b97a 100644 --- a/account_payment_promissory_note/views/account_payment_view.xml +++ b/account_payment_promissory_note/views/account_payment_view.xml @@ -4,26 +4,26 @@ account.payment - + - + account.payment - + - + diff --git a/account_payment_promissory_note/wizard/account_register_payments.py b/account_payment_promissory_note/wizard/account_register_payments.py index 7c80f764421..eb210c404da 100644 --- a/account_payment_promissory_note/wizard/account_register_payments.py +++ b/account_payment_promissory_note/wizard/account_register_payments.py @@ -9,27 +9,27 @@ class AccountRegisterPayments(models.TransientModel): _name = "account.payment.register" _inherit = ["account.payment.register", "account.promissory.note.mixin"] - def get_payments_vals(self): - vals = super().get_payments_vals() - for val in vals: + def _create_payments(self): + payments = super()._create_payments() + for payment in payments: if not self.date_due: - invoices = self.env["account.move"].browse(val["invoice_ids"][0][2]) - max_date = max(invoices.mapped("invoice_date_due")) - val.update( - {"promissory_note": self.promissory_note, "date_due": max_date} - ) + invoices = payment.reconciled_invoice_ids + if invoices: + max_date = max(invoices.mapped("invoice_date_due")) + payment.promissory_note = self.promissory_note + payment.date_due = max_date else: - val.update( - {"promissory_note": self.promissory_note, "date_due": self.date_due} - ) - return vals + payment.promissory_note = self.promissory_note + payment.date_due = self.date_due + return payments @api.onchange("promissory_note") def _onchange_promissory_note(self): - super()._onchange_promissory_note() + result = super()._onchange_promissory_note() if not self.date_due and self.promissory_note: - active_ids = self._context.get("active_ids") + active_ids = self.env.context.get("active_ids") invoices = self.env["account.move"].browse(active_ids) same_partner = len(invoices.mapped("partner_id")) == 1 if invoices and self.group_payment and same_partner: self.date_due = max(invoices.mapped("invoice_date_due")) + return result diff --git a/setup/account_payment_promissory_note/odoo/addons/account_payment_promissory_note b/setup/account_payment_promissory_note/odoo/addons/account_payment_promissory_note new file mode 120000 index 00000000000..77e7a754ed7 --- /dev/null +++ b/setup/account_payment_promissory_note/odoo/addons/account_payment_promissory_note @@ -0,0 +1 @@ +../../../../account_payment_promissory_note \ No newline at end of file diff --git a/setup/account_payment_promissory_note/setup.py b/setup/account_payment_promissory_note/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/account_payment_promissory_note/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)