[FIX] point_of_sale: barcode from pos to base.
Switch the declaration of the field barcode to the base module instead of the point_of_sale module. closes odoo/odoo#41658 Task-id: 2069831 Related: odoo/enterprise#6736 Related: odoo/upgrade#984 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
committed by
Pierre Masereel
parent
1c3d1eed01
commit
fba2f5d331
@@ -13,11 +13,6 @@ class ResPartner(models.Model):
|
||||
groups="point_of_sale.group_pos_user",
|
||||
)
|
||||
pos_order_ids = fields.One2many('pos.order', 'partner_id', readonly=True)
|
||||
barcode = fields.Char(help="Use a barcode to identify this contact from the Point of Sale.", copy=False)
|
||||
|
||||
_sql_constraints = [
|
||||
('unique_barcode', 'unique(barcode, company_id)', 'This barcode is already assigned to another contact. Please make sure you assign a unique barcode to this contact.'),
|
||||
]
|
||||
|
||||
def _compute_pos_order(self):
|
||||
partners_data = self.env['pos.order'].read_group([('partner_id', 'in', self.ids)], ['partner_id'], ['partner_id'])
|
||||
|
||||
@@ -224,6 +224,7 @@ class Partner(models.Model):
|
||||
commercial_company_name = fields.Char('Company Name Entity', compute='_compute_commercial_company_name',
|
||||
store=True)
|
||||
company_name = fields.Char('Company Name')
|
||||
barcode = fields.Char(help="Use a barcode to identify this contact.", copy=False, company_dependent=True)
|
||||
|
||||
# hack to allow using plain browse record in qweb views, and used in ir.qweb.field.contact
|
||||
self = fields.Many2one(comodel_name=_name, compute='_compute_get_ids')
|
||||
@@ -380,6 +381,11 @@ class Partner(models.Model):
|
||||
def onchange_company_type(self):
|
||||
self.is_company = (self.company_type == 'company')
|
||||
|
||||
@api.constrains('barcode')
|
||||
def _check_barcode_unicity(self):
|
||||
if self.env['res.partner'].search_count([('barcode', '=', self.barcode)]) > 1:
|
||||
raise ValidationError('An other user already has this barcode')
|
||||
|
||||
def _update_fields_values(self, fields):
|
||||
""" Returns dict of write() values for synchronizing ``fields`` """
|
||||
values = {}
|
||||
|
||||
Reference in New Issue
Block a user