Skip to Content
Menú
This question has been flagged
2 Respostes
1345 Vistes

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
Descartar
Best Answer

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
Descartar
Best Answer

hi Gowtham A:

Try this in the field defination:

reference = fields.Char(related='stock_move_id.reference', store=True)
Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de maig 25
1252
1
de febr. 25
1685
2
de juny 25
930
3
de maig 25
1801
2
de març 25
1007