Skip to Content
Menú
This question has been flagged
2 Respostes
185 Vistes

Hi!

Is it possible to add the Product's Attributes to the Order and Invoice lines with Studio, when the Product doesn't have multiple Variants?

F.e. I want it to look like this:

Airpods

Brand: Apple

Type: Headphones

Serialnumber: SNAPAP12345678


Can this be done in Studio without programming in Python?

Avatar
Descartar
Best Answer

Short answer: yes for Brand/Type it’s doable 100% in Studio with no Python. For Serial Number, use lots/serial tracking (not attributes). Here’s the clean way:

  1. Model the data on the Product (no variants)
  • Activate “Variants” in Sales/Inventory settings (needed to see Attributes).
  • Go to Products → Configuration → Attributes.
  • Create attributes “Brand” and “Type”.
  • Set “Create variants” = Never (aka “no-variant” attributes). This doesn’t create multiple variants.
  • Open your product → Attributes & Variants tab → assign Brand=Apple, Type=Headphones.
  1. Show attributes on Order/Invoice lines (forms) with Studio
  • Studio → open the Sale Order Line form (model: sale.order.line).
  • Add a new field → choose “Related” → point it to:
    product_id → product_tmpl_id → no-variant attribute values (you’ll find it as a Many2many to product.template.attribute.value; the exact label varies, but search “attribute value”).
  • Widget = many2many_tags, Label = “Attributes”.
  • Repeat the same on the Invoice Line form (model: account.move.line), related to line.product_id.product_tmpl_id → no-variant attribute values.

Result: on each line you’ll see tags like “Brand: Apple”, “Type: Headphones”.

  1. Print them on the PDF (still Studio, no Python)
  • Studio → Reports → Customer Invoice (and/or Quotation/Order).
  • Under each line, add a small block bound to:
    line.product_id.product_tmpl_id.(no-variant attribute values).
  • If the editor doesn’t render a Many2many nicely by default, add a tiny QWeb loop in the visual editor:
    • Insert a “For Each” on line.product_id.product_tmpl_id.no_variant_attribute_value_ids (name may appear as product_template_attribute_value_ids filtered to no-variant).
    • Inside, print t-esc="att.display_name".
      This stays within Studio’s report editor.
  1. Serial Number: don’t model as Attribute
  • If you track serials, use Inventory tracking (Lots/Serials). You assign the serial on the delivery; the invoice can show delivered serials by adding a section under the invoice line that lists the related move lines’ lots (Studio → Reports → add a “for each” on line.move_line_ids / stock move lines → lot_id.name).
  • If you really need to type a serial on the order before delivery, add a simple Char field on sale.order.line (x_serialnumber) with Studio and (optionally) add the same field on account.move.line and copy it over during invoicing (Studio supports copying same-named fields when the invoice is created from the order).

When to choose what

  • Brand/Type: use no-variant attributes (tidy, reusable, visible everywhere).
  • Serial numbers: use Lots/Serials (true traceability). Only use a custom Char if you must pre-capture it on the SO.

Gotchas

  • If you don’t see the “no-variant” option, you haven’t enabled Variants in settings.
  • Related Many2many fields render best with the “tags” widget on forms; for reports, a tiny for-each is usually needed.
  • Avoid making Brand/Type custom Char fields unless you must print them without touching the report attributes keep data consistent across products.

Avatar
Descartar
Best Answer

Hi,


Yes, you can add Product Attributes to Order and Invoice lines in Odoo using Studio, even without multiple variants or Python coding. Start by opening Studio in either Sales Orders or Invoices and selecting the appropriate line model (sale.order.line or account.move.line). Add custom character fields for each attribute you want to display, such as "Brand," "Type," and "Serial Number."


Next, convert these fields to Computed fields. This allows them to automatically pull data from the product. Use the formula editor to access the product's attributes, referencing the correct fields on the product.template or product.product model (e.g., record.product_id.x_product_brand). Finally, drag these new fields onto the form view of the Sales Order Line or Invoice Line and, optionally, make them read-only to prevent manual editing. This setup allows you to display product attributes on order and invoice lines using Odoo Studio without any Python code.


Reference:-

* https://www.cybrosys.com/odoo/odoo-books/v17/studio/

* https://www.youtube.com/watch?v=laF9XUPaCc4

* https://www.youtube.com/watch?v=8y5juGg5zHA


Hope it helps

Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de nov. 22
2030
0
de jul. 19
3906
1
de jul. 25
1959
2
de març 25
2136
0
de febr. 25
1720