Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
1019 Zobrazení

In valuation layer , reference field is related to stock move.

How can i manually pass the value to reference field of valuation 


stock_valuation = self.env['stock.valuation.layer'].create({
# 'create_date': create_date,
# 'stock_move_id': stock_move.id or False,
'product_id': product_id.id or False,
'company_id': company_id.id or False,
'quantity': quantity,
'unit_cost': unit_cost,
'value': value,
'description': product_des,

})
stock_valuation.write({'account_move_id': account_move.id,'reference':'Hello' })
reference = fields.Char(related='stock_move_id.reference')
Avatar
Zrušit
Nejlepší odpověď

Hi,


In your case, the reference field in valuation is a related field.

reference = fields.Char(related='stock_move_id.reference')

This means:

You cannot directly set it with write({'reference': 'Hello'}) because it's read-only and reflects the value from stock_move_id.reference.If you want to show a specific reference, you must set it on the related stock move record.


Hope it helps.

Avatar
Zrušit
Nejlepší odpověď

hi Gowtham A:

Try this in the field defination:

reference = fields.Char(related='stock_move_id.reference', store=True)
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
kvě 25
871
1
úno 25
1274
2
čvn 25
560
3
kvě 25
1419
2
bře 25
689