diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst index cc81b4fb8..98febcc3d 100644 --- a/account_payment_partner/README.rst +++ b/account_payment_partner/README.rst @@ -14,16 +14,16 @@ Account Payment Partner :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github - :target: https://github.com/OCA/bank-payment/tree/15.0/account_payment_partner + :target: https://github.com/OCA/bank-payment/tree/16.0/account_payment_partner :alt: OCA/bank-payment .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/bank-payment-15-0/bank-payment-15-0-account_payment_partner :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/173/15.0 + :target: https://runbot.odoo-community.org/runbot/173/16.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module adds several fields: @@ -127,6 +127,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_partner/__manifest__.py b/account_payment_partner/__manifest__.py index 3e8083f11..5131ae5c4 100644 --- a/account_payment_partner/__manifest__.py +++ b/account_payment_partner/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Account Payment Partner", - "version": "15.0.1.2.0", + "version": "16.0.1.0.0", "category": "Banking addons", "license": "AGPL-3", "summary": "Adds payment mode on partners and invoices", diff --git a/account_payment_partner/i18n/account_payment_partner.pot b/account_payment_partner/i18n/account_payment_partner.pot index 4f177069a..3f8974630 100644 --- a/account_payment_partner/i18n/account_payment_partner.pot +++ b/account_payment_partner/i18n/account_payment_partner.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" diff --git a/account_payment_partner/models/account_move.py b/account_payment_partner/models/account_move.py index 7c93339bf..067551caf 100644 --- a/account_payment_partner/models/account_move.py +++ b/account_payment_partner/models/account_move.py @@ -81,47 +81,28 @@ 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_id() - return res - - @api.depends("partner_id", "payment_mode_id") + @api.depends("bank_partner_id", "payment_mode_id") def _compute_partner_bank_id(self): + res = super()._compute_partner_bank_id() for move in self: # No bank account assignation is done for out_invoice as this is only # needed for printing purposes and it can conflict with # SEPA direct debit payments. Current report prints it. - def get_bank_id(): - return fields.first( - move.commercial_partner_id.bank_ids.filtered( - lambda b: b.company_id == move.company_id or not b.company_id - ) - ) + if move.move_type != "in_invoice" or not move.payment_mode_id: + move.partner_bank_id = False + continue + return res - bank_id = False - if move.partner_id: - pay_mode = move.payment_mode_id - if move.move_type == "in_invoice": - if ( - pay_mode - and pay_mode.payment_type == "outbound" - and pay_mode.payment_method_id.bank_account_required - and move.commercial_partner_id.bank_ids - ): - bank_id = get_bank_id() - move.partner_bank_id = bank_id - - def _reverse_move_vals(self, default_values, cancel=True): - move_vals = super()._reverse_move_vals(default_values, cancel=cancel) - move_vals["payment_mode_id"] = self.payment_mode_id.refund_payment_mode_id.id - if self.move_type == "in_invoice": - move_vals["partner_bank_id"] = self.partner_bank_id.id - return move_vals + def _reverse_moves(self, default_values_list=None, cancel=False): + for move, default_values in zip(self, default_values_list): + default_values[ + "payment_mode_id" + ] = move.payment_mode_id.refund_payment_mode_id.id + if move.move_type == "in_invoice": + default_values["partner_bank_id"] = move.partner_bank_id.id + return super()._reverse_moves( + default_values_list=default_values_list, cancel=cancel + ) def partner_banks_to_show(self): self.ensure_one() @@ -144,12 +125,13 @@ 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 odoo _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_id() - vals["partner_bank_id"] = virtual_move.partner_bank_id.id - return super().create(vals) + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + # Force compute partner_bank_id when invoice is created from SO + # to avoid that odoo _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_id() + vals["partner_bank_id"] = virtual_move.partner_bank_id.id + return super().create(vals_list) diff --git a/account_payment_partner/models/account_move_line.py b/account_payment_partner/models/account_move_line.py index 0664d80f5..a49a1be58 100644 --- a/account_payment_partner/models/account_move_line.py +++ b/account_payment_partner/models/account_move_line.py @@ -18,9 +18,9 @@ class AccountMoveLine(models.Model): @api.depends("move_id.payment_mode_id") def _compute_payment_mode(self): for line in self: - if line.move_id.is_invoice() and line.account_internal_type in ( - "receivable", - "payable", + if line.move_id.is_invoice() and line.account_type in ( + "asset_receivable", + "liability_payable", ): line.payment_mode_id = line.move_id.payment_mode_id else: diff --git a/account_payment_partner/static/description/index.html b/account_payment_partner/static/description/index.html index c7d61638e..dea02220a 100644 --- a/account_payment_partner/static/description/index.html +++ b/account_payment_partner/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Mature License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runbot

+

Mature License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runbot

This module adds several fields: