Skip to Content
Menu
This question has been flagged

I need to search and show product attribute values on Sales order lines.

EG: initially we have one product - shirt with 1 attributes with 4 values each.

So 

Product "Shirt"

Attribute 1 "Color" Values "Black","green","pink"and "orange"

That generates one product with 4 variants

I want to add custom columns to Sales order lines so that when i need to add a product in order line, At that time, i need to select the product -shirt in first column and in next column i need to search and select the variant names corresponding attributes are shown on Sales order line.

Avatar
Discard
Best Answer

Hello,

By odoo standard flow, all the product variant with respected attribute name will be shown in sale order lines.



And if you want to show the attribute value of product in order lines, then you need to take a new many2many field for product.attribute in order lines like

    product_template_attribute_value_ids = fields.Many2many('product.template.attribute.value', relation='product_variant_combination', string="Attribute Values", ondelete='restrict')

You need to set product.attribute value while onchange method of product in order lines model.

    @api.onchange('product_id')

    def product_id_change(self):

        super(class_name, self).product_id_change()

        if self.product_id.product_template_attribute_value_ids:

            self.product_template_attribute_value_ids = [(6, 0, self.product_id.product_template_attribute_value_ids.ids)]


Thanks.

Avatar
Discard
Related Posts Replies Views Activity
2
May 24
254
0
Oct 24
133
1
Dec 22
876
1
Aug 24
379
1
Jun 24
1113