Skip to Content
Menu
This question has been flagged
2 Replies
194 Views

When I use Odoo software for my brass products, each product has a different size, weight, and type. For these products, I need to print barcodes that include:


Product name

Size

Weight

Type

Company name

(Optional) Product photo

MRP

Wholesale price


Currently, when I print labels from Odoo, it only shows the product name and price. I want to customize the label so that all the above details appear on the barcode/label as per my requirement. Is there any option in Odoo to achieve this, or do I need a customization?


Secondly, when I create a new product in Odoo, I have to manually enter a unique code (barcode or internal reference). It is very difficult to track which codes I have already used. I want this product code to be generated automatically for each new product.


These are the two main limitations I am facing in Odoo. How can I solve them?

Avatar
Discard
Best Answer

Hi,

The best way is to configure an Odoo Sequence and link it to the default_code (internal reference) or barcode.


Sample Code:

Data file for sequence:


<odoo>

    <!-- Sequence definition for product internal reference -->

    <record id="seq_product_default_code" model="ir.sequence">

        <field name="name">Product Internal Reference</field>

        <field name="code">product.default.code</field>

        <field name="prefix">PROD/</field>

        <field name="padding">5</field>

        <field name="number_next">1</field>

        <field name="number_increment">1</field>

        <field name="company_id" eval="False"/>

    </record>

</odoo>


Python:


from odoo import api, fields, models


class ProductTemplate(models.Model):

    _inherit = "product.template"


    @api.model_create_multi

    def create(self, vals_list):

        for vals in vals_list:

            if not vals.get("default_code"):

                vals["default_code"] = self.env["ir.sequence"].next_by_code(

                    "product.default.code"

                )

        return super().create(vals_list)


Result:

internal reference = PROD/00001


Hope it helps

Avatar
Discard
Best Answer

Hi,

  1. Custom barcode/label – The standard Odoo label only shows a few fields. To add size, weight, type, company, MRP, wholesale price, or even a product image, you’ll need to customize the report template (report.product_template_label). This can be done with Studio (adding extra fields in the QWeb template) or with a small custom module if you want full control of the design.
  2. Automatic product codes – You don’t need to enter barcodes or internal references manually. You can set up a sequence so Odoo generates a unique code for every new product. In developer mode go to Technical → Sequences & Identifiers, create a sequence, and assign it to the product default_code (internal reference) or barcode field. With that, each new product gets a unique code automatically.

So: label customization = template change, unique codes = sequence.

Hope this helps!

Avatar
Discard
Related Posts Replies Views Activity
0
Feb 25
1475
0
Dec 24
46
0
Dec 24
1293
1
Oct 24
2631
2
Aug 24
1779