[FIX] pos_sale: traceback on installing sales
If a pos session is started in the automatically created pos config and the sales app is installed afterwards, a traceback will be shown. This is because pos_sale tries to make changes to the config, which are not allowed. We removed the hardcoded team in data, and manage the default value in an onchange on the company_id to keep a consistant team.
This commit is contained in:
committed by
Pierre Masereel
parent
e4cba4d037
commit
c32558e5e4
@@ -4,9 +4,6 @@
|
||||
<record id="sales_team.pos_sales_team" model="crm.team">
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
<record id="point_of_sale.pos_config_main" model="pos.config">
|
||||
<field name="crm_team_id" ref="sales_team.pos_sales_team"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import fields, models, api
|
||||
from odoo.exceptions import AccessError
|
||||
|
||||
|
||||
class PosConfig(models.Model):
|
||||
_inherit = 'pos.config'
|
||||
|
||||
def _get_default_pos_team(self):
|
||||
team = self.env['crm.team'].search(['|', ('company_id', '=', self.env.company.id), ('company_id', '=', False)], limit=1)
|
||||
return team
|
||||
|
||||
crm_team_id = fields.Many2one(
|
||||
'crm.team', string="Sales Team",
|
||||
help="This Point of sale's sales will be related to this Sales Team.",
|
||||
default=_get_default_pos_team)
|
||||
help="This Point of sale's sales will be related to this Sales Team.")
|
||||
|
||||
@api.onchange('company_id')
|
||||
def _get_default_pos_team(self):
|
||||
default_sale_team = self.env.ref('sales_team.pos_sales_team', raise_if_not_found=False)
|
||||
if default_sale_team and (not default_sale_team.company_id or default_sale_team.company_id == self.company_id):
|
||||
self.crm_team_id = default_sale_team
|
||||
else:
|
||||
self.crm_team_id = self.env['crm.team'].search(['|', ('company_id', '=', self.company_id.id), ('company_id', '=', False)], limit=1)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
<record id="pos_sales_team" model="crm.team">
|
||||
<field name="name">Point of Sale</field>
|
||||
<field name="company_id" eval="False"/>
|
||||
<field name="active" eval="False"/>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user