diff --git a/account_payment_purchase/README.rst b/account_payment_purchase/README.rst index 1418325fa..b1829004c 100644 --- a/account_payment_purchase/README.rst +++ b/account_payment_purchase/README.rst @@ -23,7 +23,7 @@ Account Payment Purchase :target: https://runbot.odoo-community.org/runbot/173/14.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module adds 2 fields on purchase orders: *Bank Account* and *Payment Mode*. These fields are copied from partner to purchase order and then from @@ -113,6 +113,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/bank-payment `_ project on GitHub. +This module is part of the `OCA/bank-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_purchase/__manifest__.py b/account_payment_purchase/__manifest__.py index 3d4b4108c..a2d3a535d 100644 --- a/account_payment_purchase/__manifest__.py +++ b/account_payment_purchase/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Account Payment Purchase", - "version": "14.0.1.0.1", + "version": "15.0.1.0.0", "category": "Banking addons", "license": "AGPL-3", "summary": "Adds Bank Account and Payment Mode on Purchase Orders", diff --git a/account_payment_purchase/models/__init__.py b/account_payment_purchase/models/__init__.py index fbd9ff8ae..1d9a05322 100644 --- a/account_payment_purchase/models/__init__.py +++ b/account_payment_purchase/models/__init__.py @@ -1,3 +1,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import account_invoice, purchase_order +from . import account_move, purchase_order diff --git a/account_payment_purchase/models/account_invoice.py b/account_payment_purchase/models/account_move.py similarity index 85% rename from account_payment_purchase/models/account_invoice.py rename to account_payment_purchase/models/account_move.py index 774849038..04fc39c01 100644 --- a/account_payment_purchase/models/account_invoice.py +++ b/account_payment_purchase/models/account_move.py @@ -19,12 +19,14 @@ class AccountMove(models.Model): "message": _("Selected purchase order have different payment mode."), } return res - self.payment_mode_id = new_mode + elif self.payment_mode_id.id != new_mode: + self.payment_mode_id = new_mode if self.partner_bank_id and new_bank and self.partner_bank_id.id != new_bank: res["warning"] = { "title": _("Warning"), "message": _("Selected purchase order have different supplier bank."), } return res - self.partner_bank_id = new_bank + elif self.partner_bank_id.id != new_bank: + self.partner_bank_id = new_bank return res diff --git a/account_payment_purchase/models/purchase_order.py b/account_payment_purchase/models/purchase_order.py index dba0243e8..6bb4f92af 100644 --- a/account_payment_purchase/models/purchase_order.py +++ b/account_payment_purchase/models/purchase_order.py @@ -29,7 +29,7 @@ class PurchaseOrder(models.Model): @api.onchange("partner_id", "company_id") def onchange_partner_id(self): - super(PurchaseOrder, self).onchange_partner_id() + ret = super(PurchaseOrder, self).onchange_partner_id() if self.partner_id: self.supplier_partner_bank_id = self._get_default_supplier_partner_bank( self.partner_id @@ -38,3 +38,4 @@ class PurchaseOrder(models.Model): else: self.supplier_partner_bank_id = False self.payment_mode_id = False + return ret diff --git a/account_payment_purchase/tests/test_account_payment_purchase.py b/account_payment_purchase/tests/test_account_payment_purchase.py index 3464aea6b..67b65d4ed 100644 --- a/account_payment_purchase/tests/test_account_payment_purchase.py +++ b/account_payment_purchase/tests/test_account_payment_purchase.py @@ -3,23 +3,18 @@ # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from odoo import fields -from odoo.tests import Form, SavepointCase +from odoo.tests import Form, TransactionCase -class TestAccountPaymentPurchase(SavepointCase): +class TestAccountPaymentPurchase(TransactionCase): @classmethod def setUpClass(cls): super(TestAccountPaymentPurchase, cls).setUpClass() cls.journal = cls.env["account.journal"].create( {"name": "Test journal", "code": "TEST", "type": "general"} ) - cls.payment_method_out = cls.env["account.payment.method"].create( - { - "name": "Test payment method", - "code": "test", - "payment_type": "outbound", - "bank_account_required": True, - } + cls.payment_method_out = cls.env.ref( + "account.account_payment_method_manual_out" ) cls.payment_mode = cls.env["account.payment.mode"].create( { diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..32b319aa0 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +git+https://github.com/OCA/bank-payment@refs/pull/873/head#subdirectory=setup/account_payment_partner +git+https://github.com/OCA/bank-payment@refs/pull/870/head#subdirectory=setup/account_payment_mode