[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 <pimodoo@users.noreply.github.com>
This commit is contained in:
Gert Pellin
2019-07-05 12:34:29 +00:00
committed by Pierre Masereel
parent b85b584c34
commit 3ca2842cc1
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -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
+2 -2
View File
@@ -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_)