Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
9874 มุมมอง

I would like to assign custom EAN13 codes for all products.

Is there any easy option to generate an EAN13 code for every new product?

It might be something simple like a sequence which is increased for every product introduced in the database, prefixed with the right manufacturer code and with the right appended control digit

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Since none of the samples added actual code and only referred to apps to download I decided to add a minimal code sample for whoever lands here after:

import random

class ProductTemplate(models.Model):
_inherit = "product.template

def generate_new_ean13(self):
return self.env['barcode.nomenclature'].sudo().sanitize_ean(str("%0.13d" % random.randint(0, 999999999999)))

This will generate a random EAN13 based on a random number from 0-999999999999. By using Odoo's default "sanitize_ean" function Odoo will make sure it is a validly formatted EAN13.

Note: don't forget to cover some duplicate checks ;)

Regards,
Yenthe

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You test this solution from Odoo apps:  https://www.odoo.com/apps/modules/8.0/product_barcode_generator/

or this:

https://www.odoo.com/apps/modules/8.0/product_barcode_generator_custom/  

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

I tried https://www.odoo.com/apps/modules/8.0/product_barcode_generator/, without success.

I installed the module and reload everything.

I see you can select a sequence both in company and in product category. I populated both and tried to create a new product. Nothing happens to product EAN13 field

I wonder if this is just for POS (I am not using POS). or if I am just missing how it works.

I also tried to look for more specific documentation but I was not able to find it.

อวตาร
ละทิ้ง

Button 'Generate the EAN13' is visible only on product.product view (Product Variant view) not on product.template view. And works on demand.

คำตอบที่ดีที่สุด

this module is not automatically because you must use button.

https://www.odoo.com/apps/modules/8.0/product_barcode_generator/

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to print barcode for products แก้ไขแล้ว
5
ธ.ค. 23
18098
Removing Barcode แก้ไขแล้ว
3
ก.ค. 21
4550
1
มี.ค. 15
3691
1
มี.ค. 15
3268
1
มี.ค. 15
4792