[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:
@@ -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">
|
||||
|
||||
@@ -169,7 +169,6 @@ class Partner(models.Model):
|
||||
category_id = fields.Many2many('res.partner.category', column1='partner_id',
|
||||
column2='category_id', string='Tags', default=_default_category)
|
||||
credit_limit = fields.Float(string='Credit Limit')
|
||||
barcode = fields.Char(oldname='ean13', help="Use a barcode to identify this contact from the Point of Sale.")
|
||||
active = fields.Boolean(default=True)
|
||||
customer = fields.Boolean(string='Is a Customer', default=True,
|
||||
help="Check this box if this contact is a customer. It can be selected in sales orders.")
|
||||
|
||||
@@ -385,9 +385,6 @@
|
||||
<group string="Purchase" name="purchase" priority="2">
|
||||
<field name="supplier"/>
|
||||
</group>
|
||||
<group string="Point Of Sale">
|
||||
<field name="barcode"/>
|
||||
</group>
|
||||
<group name="misc" string="Misc">
|
||||
<field name="ref" string="Reference"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
|
||||
Reference in New Issue
Block a user