Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
1501 Vues

when i make a scan to barcode is not equal to the barcode in the product 

Avatar
Ignorer
Meilleure réponse

Hi,

If your product's barcode is generated automatically, check to see that it is functioning properly.
Then check the barcode of the corresponding product while scanning the barcode.

Let's say there is a field for scanning the barcode when the product moves, in that case you can use the following code:

scan_barcode = fields.Char(
string="scan product",
help="scan barcode of product here")

@api.onchange('scan_barcode')
def onchange_scan_barcode(self):
"""checking barcode with the corresponding product"""
order_product = self.env['product.product'].search(
[('barcode', '=', self.scan_barcode)])
lst=[]
if order_product:
for rec in self.move_ids:
lst.append(rec.product_id.id)
for rec in self.move_ids:
if order_product.id in lst:
if order_product.id == rec.product_id.id:
po= self.env['purchase.order'].search([('name','=',self.origin)])
for product in po.order_line:
if product.product_id.id == rec.product_id.id:
rec.scanned_count += 1
rec.product_uom_qty += 1
rec.product_barcode=self.scan_barcode
self.scan_barcode = 0
break
else:
vals = {
'name': order_product.name,
'product_id': order_product.id,
'reference': rec.reference,
'product_uom_qty': 1,
'product_barcode':self.scan_barcode,
'product_uom': order_product.uom_id.id,
'picking_type_id': rec.picking_type_id.id,
'origin': rec.origin,
'scanned_count':1,
'location_id': rec.location_id,
'location_dest_id':rec.location_dest_id
}
self.write({
'move_ids': [(0, 0, vals),]
})
lst.append(order_product.id)
break
else:
raise ValidationError(_('Sorry there is no product with such barcode'))
self.scan_barcode = 0

Regards 

Avatar
Ignorer
Publications associées Réponses Vues Activité
0
nov. 24
403
2
juil. 23
1453
0
juil. 23
849
0
avr. 25
97
0
déc. 24
1940