[IMP]base: Unique barcode for customers.

If two customers have same barcode -
Current functionality : To select customer in POS, if we scan barcode, only the newly created customer will be selected.

To resolve this: Created the unique sql constraint for customer per company.
This commit is related to task# 1877329.

closes odoo/odoo#28316
This commit is contained in:
Pratima Gupta
2019-01-15 04:45:36 +00:00
parent 4155bc5614
commit 2f4ec15a37
4 changed files with 11 additions and 4 deletions
@@ -11,6 +11,11 @@ class ResPartner(models.Model):
help="The number of point of sales orders related to this customer",
groups="point_of_sale.group_pos_user",
)
barcode = fields.Char(oldname='ean13', 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'])
@@ -15,6 +15,12 @@
<field string="POS Sales" name="pos_order_count" widget="statinfo"/>
</button>
</button>
<xpath expr="//group[@name='purchase']" position="after">
<group string="Point Of Sale" name="point_of_sale">
<field name="barcode"/>
</group>
</xpath>
</field>
</record>
<record id="view_partner_pos_kanban" model="ir.ui.view">