From 7167961fbfa1734cfac91f3bdde129dadf9270f4 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Fri, 17 Dec 2021 12:43:22 +0000 Subject: [PATCH] [FIX] sale: Payment had wrong sales team Current behavior : When creating payment from invoice, the payment had the wrong sales team id Steps to reproduce : - Create atleast 2 invoices with different sales team and same partner - Register payments for every invoice - Go in payments list view - Filter on partner and group by sales team - All the payments are grouped in the same sales team opw-2681041 closes odoo/odoo#82114 X-original-commit: 2f3ebe86b2d520dd9c7570f60056f200bb091aab Signed-off-by: Engels Robin (roen) Signed-off-by: Victor Feyens (vfe) --- addons/sale/wizard/__init__.py | 1 + addons/sale/wizard/account_payment_register.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 addons/sale/wizard/account_payment_register.py diff --git a/addons/sale/wizard/__init__.py b/addons/sale/wizard/__init__.py index 40ded784140..34ae33af786 100644 --- a/addons/sale/wizard/__init__.py +++ b/addons/sale/wizard/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import account_payment_register from . import mail_compose_message from . import payment_acquirer_onboarding_wizard from . import sale_make_invoice_advance diff --git a/addons/sale/wizard/account_payment_register.py b/addons/sale/wizard/account_payment_register.py new file mode 100644 index 00000000000..cc13e16bc8c --- /dev/null +++ b/addons/sale/wizard/account_payment_register.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +from odoo import models + + +class AccountPaymentRegister(models.TransientModel): + _inherit = 'account.payment.register' + + def _create_payment_vals_from_wizard(self): + vals = super()._create_payment_vals_from_wizard() + # Make sure the account move linked to generated payment + # belongs to the expected sales team + # team_id field on account.payment comes from the `_inherits` on account.move model + vals.update({'team_id': self.line_ids.move_id[0].team_id.id}) + return vals