summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Heinz <rhe@odoo.com>2019-12-10 15:00:18 +0000
committerPierre Masereel <pim@odoo.com>2020-03-30 08:42:26 +0000
commitfba2f5d33105eb20a4c2689a1ddba97d50c47c40 (patch)
tree8be09e20e72f122c4fea2eccf2733ca8520b8fbc
parent1c3d1eed015b2fc19245657ae861a3cb6831bde8 (diff)
[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>
-rw-r--r--addons/point_of_sale/models/res_partner.py5
-rw-r--r--odoo/addons/base/models/res_partner.py6
2 files changed, 6 insertions, 5 deletions
diff --git a/addons/point_of_sale/models/res_partner.py b/addons/point_of_sale/models/res_partner.py
index bcfe3012259..a0246c6fadb 100644
--- a/addons/point_of_sale/models/res_partner.py
+++ b/addons/point_of_sale/models/res_partner.py
@@ -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'])
diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py
index cb5d5f6b174..14e8c634339 100644
--- a/odoo/addons/base/models/res_partner.py
+++ b/odoo/addons/base/models/res_partner.py
@@ -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 = {}