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

Hi,

Don't understand why I can't retrieve the value of a related selection field in stock.move. I have added a custom product_packaging selection field in product.template . And in stock_move I have added the same selection field which I related. A piece of code:


class product_template(models.Model):

    product_packaging = fields.Selection(string='Packaging', selection=[

        ('unit', 'Unit'),

        ('by_two', 'By 2'),

        ('by_three', 'By 3'),

        ('by_four', 'By 4')

    ])


class stock_move(models.Model):

    product_packaging = fields.Selection(string='Packaging',  

        selection=[

        ('unit', 'Unit'),

        ('by_two', 'By 2'),

        ('by_three', 'By 3'),

        ('by_four', 'By 4')],

        related='product_tmpl_id.product_packaging')


But I can't understand why my field is not retrieved when I display stock move.

Could someone help ?

Avatar
Discard
Author Best Answer

Thanks for your answer.

Finally, I found the culprit. There is already a product_packaging field in stock.move in Odoo. But it uses the packaging tools embedded in it and our customer just want a basic system so we created our own. But I gave the same name to the field in stock.move. I changed it and all is working as expected, now.

Avatar
Discard
Best Answer

hello,

- field product_tmpl_id in object stock.move is related to product_id
- you can try  related='product_id.product_tmpl_id.product_packaging'

It work for me.

Avatar
Discard