Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
maj 24
1108
0
paź 24
765
1
gru 22
1712
1
kwi 25
2182
1
cze 24
2336