Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1145 Vistas

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
Mejor respuesta

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
Mejor respuesta

hi Gowtham A:

Try this in the field defination:

reference = fields.Char(related='stock_move_id.reference', store=True)
Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
may 25
1046
1
feb 25
1425
2
jun 25
700
3
may 25
1535
2
mar 25
820