From 3ca2842cc137747f5164f69697337205dd136f9d Mon Sep 17 00:00:00 2001 From: Gert Pellin Date: Wed, 19 Jun 2019 14:41:18 +0000 Subject: [PATCH] [IMP] pos_sale: store sales team on pos order For now the sales team is only used on the pos.config and now on the invoices generated. When you open the sale report, you'll see the sales team of the pos.order, but in reality it is the one of the related pos config. That means that if you change the pos team on a config. It will change the pos team of all existing order. We should store sales team on pos order, like on invoice and sale order TASK-ID: 2011460 closes odoo/odoo#34246 Signed-off-by: pimodoo --- addons/pos_sale/models/pos_order.py | 6 +++++- addons/pos_sale/report/sale_report.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/pos_sale/models/pos_order.py b/addons/pos_sale/models/pos_order.py index 5b9e8206e90..456c6a56a42 100644 --- a/addons/pos_sale/models/pos_order.py +++ b/addons/pos_sale/models/pos_order.py @@ -7,7 +7,11 @@ from odoo import api, fields, models class PosOrder(models.Model): _inherit = 'pos.order' + def _default_crm_team(self): + return self._default_session().config_id.crm_team_id + currency_rate = fields.Float("Currency Rate", compute='_compute_currency_rate', store=True, digits=(12, 6), readonly=True, help='The rate of the currency to the currency of rate applicable at the date of the order') + crm_team_id = fields.Many2one('crm.team', string="Sales Team", default=_default_crm_team) @api.depends('pricelist_id.currency_id', 'date_order', 'company_id') def _compute_currency_rate(self): @@ -18,5 +22,5 @@ class PosOrder(models.Model): @api.multi def _prepare_invoice(self): invoice_vals = super(PosOrder, self)._prepare_invoice() - invoice_vals['team_id'] = self.config_id.crm_team_id + invoice_vals['team_id'] = self.crm_team_id return invoice_vals diff --git a/addons/pos_sale/report/sale_report.py b/addons/pos_sale/report/sale_report.py index 561d3698095..ec2a6ee84cb 100644 --- a/addons/pos_sale/report/sale_report.py +++ b/addons/pos_sale/report/sale_report.py @@ -49,7 +49,7 @@ class SaleReport(models.Model): t.categ_id AS categ_id, pos.pricelist_id AS pricelist_id, NULL AS analytic_account_id, - config.crm_team_id AS team_id, + pos.crm_team_id AS team_id, p.product_tmpl_id, partner.country_id AS country_id, partner.industry_id AS industry_id, @@ -102,7 +102,7 @@ class SaleReport(models.Model): partner.industry_id, partner.commercial_partner_id, u.factor, - config.crm_team_id + pos.crm_team_id ''' current = '(SELECT %s FROM %s GROUP BY %s)' % (select_, from_, groupby_)