Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3 Antwoorden
5031 Weergaven

Hey! In stock.warehouse.orderpoint we have a field for minimum quantity. I want that field in my product.template model to. So that whatever minimum quantity is defined in the "Reorder rule" that value must be in the separate field in my form/tree view of product.template.

I am trying to use related field but it makes me select the record to fetch the value and i dont want that. Value must come by itself without any selection at all. Below are my related fields


re_order = fields.Many2one('stock.warehouse.orderpoint',string = 'Reorder', store=True)

min_qty = fields.Float(related='re_order.product_min_qty',string = 'Minimum Quantity', store=True)
Some help would be nice. Thanks in advance
Avatar
Annuleer

Do you want to modify it from product.template or just for viewing?

Auteur

I just want to view that field in product template tree view for each product. Kindly help i'll be very thankful

Beste antwoord

You can use computed field as below: 

min_qty = fields.Float(compute='_get_min_qty', string='Minimum Quantity')
def _get_min_qty(self):
for prod_tml in self:
product = self.env['product.product'].search([('product_tmpl_id','=',prod_tml.id)])
product_reorder = self.env['stock.warehouse.orderpoint'].search([('product_id','=',product.id)],limit=1)
if product_reorder:
prod_tml.min_qty= product_reorder.product_min_qty
Avatar
Annuleer
Auteur

Hey man Thank you so much, This worked like a char,. Just one question y i am not able to inherit and add this working field in tree view it is giving this error

" ValueError: Expected singleton: product.product(10, 11, 12)".

Auteur

ok this is fixed to i just had to put an else and use @api.depends and multi. Thanks

Gerelateerde posts Antwoorden Weergaven Activiteit
3
jul. 22
7524
2
apr. 24
9144
1
mrt. 15
3739
1
mei 21
4438
2
jan. 20
3262