summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorPratima Gupta <pgu@odoo.com>2018-10-31 09:35:42 +0000
committerPratima Gupta <pgu@odoo.com>2019-01-15 04:45:36 +0000
commit2f4ec15a37b916d0ea15665946de118564e4f3df (patch)
tree7c04c62ee1f23ee7922c8eec780d5f73d85a9f20 /addons
parent4155bc5614b169fe6b7470448e39b5f2fb9844dc (diff)
[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
Diffstat (limited to 'addons')
-rw-r--r--addons/point_of_sale/models/res_partner.py5
-rw-r--r--addons/point_of_sale/views/res_partner_view.xml6
2 files changed, 11 insertions, 0 deletions
diff --git a/addons/point_of_sale/models/res_partner.py b/addons/point_of_sale/models/res_partner.py
index 5f005d308cb..a4b33c150fa 100644
--- a/addons/point_of_sale/models/res_partner.py
+++ b/addons/point_of_sale/models/res_partner.py
@@ -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'])
diff --git a/addons/point_of_sale/views/res_partner_view.xml b/addons/point_of_sale/views/res_partner_view.xml
index c537a7dda5c..7721b183b08 100644
--- a/addons/point_of_sale/views/res_partner_view.xml
+++ b/addons/point_of_sale/views/res_partner_view.xml
@@ -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">