Mapear una caracteritica como columna

Home   »   Mapear una caracteritica como columna

# Copyright YEAR(S), AUTHOR(S)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

from odoo import fields, models


class mrpProduction(models.Model):
    _name = 'mrp.production'

    color_id = fields.Many2one(
        'product.template.attribute.value',
        string='Color',
    )
    material_id = fields.Many2one(
        'product.template.attribute.value',
        string='material',
    )

    def compute_variant(self):
        for record in self:
            color = record.product_id.product_template_attribute_value_ids.filtered(lambda x: x.attribute_id.name =='color')
            if color:
                record.color_id.color = color.id
            material = record.product_id.product_template_attribute_value_ids.filtered(lambda x: x.attribute_id.name =='material')
            if material:
                record.material_id.color =material.id

Leave a Reply

Your email address will not be published. Required fields are marked *