diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst index 4e9e8e684..15ee4b252 100644 --- a/account_payment_partner/README.rst +++ b/account_payment_partner/README.rst @@ -38,7 +38,7 @@ Invoices without any payment mode are displayed to. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/173/10.0 + :target: https://runbot.odoo-community.org/runbot/173/11.0 Known issues / Roadmap ====================== @@ -71,12 +71,12 @@ Contributors Maintainer ---------- -.. image:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. 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. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py index 3845dd2da..50def6204 100644 --- a/account_payment_partner/__init__.py +++ b/account_payment_partner/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- # © 2014 Akretion - Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models diff --git a/account_payment_partner/__manifest__.py b/account_payment_partner/__manifest__.py index c38f46c9c..2d29082d2 100644 --- a/account_payment_partner/__manifest__.py +++ b/account_payment_partner/__manifest__.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # © 2014 Akretion - Alexis de Lattre # © 2014 Tecnativa - Pedro M. Baeza -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name': 'Account Payment Partner', - 'version': '10.0.1.1.0', + 'version': '11.0.1.0.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': 'Adds payment mode on partners and invoices', diff --git a/account_payment_partner/models/account_invoice.py b/account_payment_partner/models/account_invoice.py index cc50ce9b5..e858875a0 100644 --- a/account_payment_partner/models/account_invoice.py +++ b/account_payment_partner/models/account_invoice.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2014-2016 Akretion - Alexis de Lattre # © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import models, fields, api @@ -22,20 +22,25 @@ class AccountInvoice(models.Model): res = super(AccountInvoice, self)._onchange_partner_id() if self.partner_id: if self.type == 'in_invoice': - pay_mode = self.partner_id.supplier_payment_mode_id + pay_mode = self.with_context( + company_id=self.company_id.id + ).partner_id.supplier_payment_mode_id self.payment_mode_id = pay_mode if ( - pay_mode and - pay_mode.payment_type == 'outbound' and - pay_mode.payment_method_id.bank_account_required and - self.commercial_partner_id.bank_ids): - self.partner_bank_id =\ + pay_mode and + pay_mode.payment_type == 'outbound' and + pay_mode.payment_method_id.bank_account_required and + self.commercial_partner_id.bank_ids + ): + self.partner_bank_id = \ self.commercial_partner_id.bank_ids[0] elif self.type == 'out_invoice': - pay_mode = self.partner_id.customer_payment_mode_id + pay_mode = self.with_context( + company_id=self.company_id.id + ).partner_id.customer_payment_mode_id self.payment_mode_id = pay_mode if pay_mode and pay_mode.bank_account_link == 'fixed': - self.partner_bank_id = pay_mode.fixed_journal_id.\ + self.partner_bank_id = pay_mode.fixed_journal_id. \ bank_account_id else: self.payment_mode_id = False @@ -43,6 +48,18 @@ class AccountInvoice(models.Model): self.partner_bank_id = False return res + @api.onchange('payment_mode_id') + def _onchange_payment_mode_id(self): + pay_mode = self.payment_mode_id + if ( + pay_mode and + pay_mode.payment_type == 'outbound' and not + pay_mode.payment_method_id.bank_account_required + ): + self.partner_bank_id = False + elif not self.payment_mode_id: + self.partner_bank_id = False + @api.model def create(self, vals): """Fill the payment_mode_id from the partner if none is provided on @@ -61,17 +78,6 @@ class AccountInvoice(models.Model): ) return super(AccountInvoice, self).create(vals) - @api.onchange('payment_mode_id') - def payment_mode_id_change(self): - if ( - self.payment_mode_id and - self.payment_mode_id.payment_type == 'outbound' and - not self.payment_mode_id.payment_method_id. - bank_account_required): - self.partner_bank_id = False - elif not self.payment_mode_id: - self.partner_bank_id = False - @api.model def line_get_convert(self, line, part): """Copy payment mode from invoice to account move line""" diff --git a/account_payment_partner/models/account_move_line.py b/account_payment_partner/models/account_move_line.py index e5fa4d492..9bdcec4e6 100644 --- a/account_payment_partner/models/account_move_line.py +++ b/account_payment_partner/models/account_move_line.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# © 2016 Akretion (http://www.akretion.com/) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# © 2016 Akretion (https://www.akretion.com/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import models, fields @@ -9,4 +9,8 @@ class AccountMoveLine(models.Model): _inherit = 'account.move.line' payment_mode_id = fields.Many2one( - 'account.payment.mode', string='Payment Mode', ondelete='restrict') + 'account.payment.mode', + string='Payment Mode', + domain="[('company_id', '=', company_id)]", + ondelete='restrict' + ) diff --git a/account_payment_partner/models/res_partner.py b/account_payment_partner/models/res_partner.py index 9b8357141..246c8739c 100644 --- a/account_payment_partner/models/res_partner.py +++ b/account_payment_partner/models/res_partner.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2014 Akretion - Alexis de Lattre # © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import models, fields, api @@ -13,12 +13,14 @@ class ResPartner(models.Model): supplier_payment_mode_id = fields.Many2one( 'account.payment.mode', string='Supplier Payment Mode', company_dependent=True, - domain=[('payment_type', '=', 'outbound')], + domain="[('payment_type', '=', 'outbound'), " + "('company_id', '=', company_id)]", help="Select the default payment mode for this supplier.") customer_payment_mode_id = fields.Many2one( 'account.payment.mode', string='Customer Payment Mode', company_dependent=True, - domain=[('payment_type', '=', 'inbound')], + domain="[('payment_type', '=', 'inbound'), " + "('company_id', '=', company_id)]", help="Select the default payment mode for this customer.") @api.model diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml index b2553be57..859e4572c 100644 --- a/account_payment_partner/views/account_invoice_view.xml +++ b/account_payment_partner/views/account_invoice_view.xml @@ -1,7 +1,7 @@ @@ -26,7 +26,7 @@ @@ -44,13 +44,14 @@ - [('partner_id', '=', commercial_partner_id)] + [('partner_id', '=', commercial_partner_id), + '|',('company_id', '=', company_id),('company_id', '=', False)] 0 {'invisible': [('bank_account_required', '=', False)], 'required': [('bank_account_required', '=', True)]} diff --git a/account_payment_partner/views/account_move_line.xml b/account_payment_partner/views/account_move_line.xml index 51cba50df..1abe8b5e1 100644 --- a/account_payment_partner/views/account_move_line.xml +++ b/account_payment_partner/views/account_move_line.xml @@ -1,9 +1,9 @@ diff --git a/account_payment_partner/views/res_partner_view.xml b/account_payment_partner/views/res_partner_view.xml index bf545cb1d..ad7ceeafe 100644 --- a/account_payment_partner/views/res_partner_view.xml +++ b/account_payment_partner/views/res_partner_view.xml @@ -1,8 +1,8 @@