Přejít na obsah
Menu
This question has been flagged
1 Odpovědět
2187 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
lis 24
1518
2
čvc 23
2163
0
čvc 23
1573
0
dub 25
1240
0
pro 24
3035