This question has been flagged

Hello All,

i have a Many2one('product_weight') field in sales order based on product.product. And i try to return that field values in sales order line(product).  In product.template i added a check_box('is_weight'). So, in sales order for 'product_weight' only weight products are available. So, how to return that 'product_weight' value in sales order line(product_id) ?

My code is here:

class sale_order_pet(models.Model):

    _inherit = "sale.order"

 product_weight = fields.Many2one('product.product', string='Service products', domain="[('is_weight','=',True)]")


    @api.onchange('product_id')

    def _onchange_action_weight_add(self):

        res = self.product_id

        print"resss:::", res

        if res:

            line_values = {'product_id': self.product_weight.id,

                           }

            sale_order_line = self.env['sale.order.line'].create(line_values)


Thanks in advance

Avatar
Discard