From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/pos_sale/models/pos_config.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 addons/pos_sale/models/pos_config.py (limited to 'addons/pos_sale/models/pos_config.py') diff --git a/addons/pos_sale/models/pos_config.py b/addons/pos_sale/models/pos_config.py new file mode 100644 index 00000000..c6a8dd7c --- /dev/null +++ b/addons/pos_sale/models/pos_config.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, api +from odoo.exceptions import AccessError + + +class PosConfig(models.Model): + _inherit = 'pos.config' + + + crm_team_id = fields.Many2one( + 'crm.team', string="Sales 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) -- cgit v1.2.3