From 5e2d1b22873d527a9376367664e18d48b3b619e5 Mon Sep 17 00:00:00 2001 From: Flectra Community Bot Date: Sun, 18 Jul 2021 02:12:53 +0000 Subject: [PATCH] Automatic Update form OCA2FC Migrator --- README.md | 4 ++-- account_payment_order/__manifest__.py | 2 +- account_payment_order/models/account_move.py | 2 +- account_payment_partner/__manifest__.py | 2 +- .../models/account_move.py | 20 +++++++++++++++++++ .../tests/test_account_payment_partner.py | 12 ++++++++++- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8e39c01..e2492fe 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ addon | version | summary --- | --- | --- [account_banking_mandate](account_banking_mandate/) | 2.0.1.1.0| Banking mandates [account_payment_order_return](account_payment_order_return/) | 2.0.1.0.1| Account Payment Order Return -[account_payment_order](account_payment_order/) | 2.0.1.2.1| Account Payment Order +[account_payment_order](account_payment_order/) | 2.0.1.2.2| Account Payment Order [account_payment_sale](account_payment_sale/) | 2.0.1.0.0| Adds payment mode on sale orders [account_payment_purchase_stock](account_payment_purchase_stock/) | 2.0.1.0.0| Integrate Account Payment Purchase with Stock [account_payment_purchase](account_payment_purchase/) | 2.0.1.0.0| Adds Bank Account and Payment Mode on Purchase Orders -[account_payment_partner](account_payment_partner/) | 2.0.1.2.0| Adds payment mode on partners and invoices +[account_payment_partner](account_payment_partner/) | 2.0.1.2.1| Adds payment mode on partners and invoices [account_banking_pain_base](account_banking_pain_base/) | 2.0.1.0.0| Base module for PAIN file generation [account_banking_sepa_direct_debit](account_banking_sepa_direct_debit/) | 2.0.1.1.0| Create SEPA files for Direct Debit [account_banking_sepa_credit_transfer](account_banking_sepa_credit_transfer/) | 2.0.1.0.0| Create SEPA XML files for Credit Transfers diff --git a/account_payment_order/__manifest__.py b/account_payment_order/__manifest__.py index 7cb4b16..a63b6f5 100644 --- a/account_payment_order/__manifest__.py +++ b/account_payment_order/__manifest__.py @@ -8,7 +8,7 @@ { "name": "Account Payment Order", - "version": "2.0.1.2.1", + "version": "2.0.1.2.2", "license": "AGPL-3", "author": "ACSONE SA/NV, " "Therp BV, " diff --git a/account_payment_order/models/account_move.py b/account_payment_order/models/account_move.py index dfcaa6f..140abf6 100644 --- a/account_payment_order/models/account_move.py +++ b/account_payment_order/models/account_move.py @@ -84,7 +84,7 @@ class AccountMove(models.Model): raise UserError(_("No Payment Mode on invoice %s") % move.name) for payment_mode in payment_modes: payorder = apoo.search( - self.get_account_payment_domain(payment_mode), limit=1 + move.get_account_payment_domain(payment_mode), limit=1 ) new_payorder = False if not payorder: diff --git a/account_payment_partner/__manifest__.py b/account_payment_partner/__manifest__.py index a83ca12..21be414 100644 --- a/account_payment_partner/__manifest__.py +++ b/account_payment_partner/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Account Payment Partner", - "version": "2.0.1.2.0", + "version": "2.0.1.2.1", "category": "Banking addons", "license": "AGPL-3", "summary": "Adds payment mode on partners and invoices", diff --git a/account_payment_partner/models/account_move.py b/account_payment_partner/models/account_move.py index f9bfa7c..ed11503 100644 --- a/account_payment_partner/models/account_move.py +++ b/account_payment_partner/models/account_move.py @@ -80,6 +80,15 @@ class AccountMove(models.Model): partner.supplier_payment_mode_id.refund_payment_mode_id ) + @api.onchange("partner_id") + def _onchange_partner_id(self): + """Force compute because the onchange chain doesn't call + ``_compute_partner_bank``. + """ + res = super()._onchange_partner_id() + self._compute_partner_bank() + return res + @api.depends("partner_id", "payment_mode_id") def _compute_partner_bank(self): for move in self: @@ -131,3 +140,14 @@ class AccountMove(models.Model): ) # Return this as empty recordset return self.partner_bank_id + + @api.model + def create(self, vals): + """Force compute partner_bank_id when invoice is created from SO + to avoid that flectra _prepare_invoice method value will be set. + """ + if self.env.context.get("active_model") == "sale.order": # pragma: no cover + virtual_move = self.new(vals) + virtual_move._compute_partner_bank() + vals["partner_bank_id"] = virtual_move.partner_bank_id + return super().create(vals) diff --git a/account_payment_partner/tests/test_account_payment_partner.py b/account_payment_partner/tests/test_account_payment_partner.py index 8ea098a..7767a5a 100644 --- a/account_payment_partner/tests/test_account_payment_partner.py +++ b/account_payment_partner/tests/test_account_payment_partner.py @@ -173,7 +173,7 @@ class TestAccountPaymentPartner(SavepointCase): cls.journal_bank = cls.env["res.partner.bank"].create( { "acc_number": "GB95LOYD87430237296288", - "partner_id": cls.env.user.company_id.id, + "partner_id": cls.env.user.company_id.partner_id.id, } ) cls.journal = cls.env["account.journal"].create( @@ -228,6 +228,16 @@ class TestAccountPaymentPartner(SavepointCase): self.payment_mode_model, ) + def test_partner_id_changes_compute_partner_bank(self): + # Test _compute_partner_bank is executed when partner_id changes + move_form = Form( + self.env["account.move"].with_context(default_move_type="out_invoice") + ) + self.assertFalse(move_form.partner_bank_id) + move_form.partner_id = self.customer + self.assertEqual(move_form.payment_mode_id, self.customer_payment_mode) + self.assertFalse(move_form.partner_bank_id) + def test_out_invoice_onchange(self): # Test the onchange methods in invoice invoice = self.move_model.new(