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

How is it possible to create the attributes and attribute avalues of the corresponding product in the product_id

in the sale.order.line?

Avatar
Discard

Check this module and see whether it helps in your use case: https://github.com/pledra/odoo-product-configurator

Best Answer

first create attribute and attribute values in the product.product model like

class ProductProduct(models.Model):
    _inherit = 'product.product'
    attribute = fields.Char()
    attribute_value = fields.Char()

Then add attribute and attribute value to the sale.order.line

class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'
    attribute = fields.Char(related='product_id.attribute')
    attribute_value = fields.Char(related='product_id.attribute_value')

Then add the attribute and attribute value in the sale order line via xml

<xpath expr="//field[@name='order_line']/tree" position="inside">
    <field name="attribute"/>
    <field name="attribute_value"/>
</xpath>
Avatar
Discard