跳至內容
選單
此問題已被標幟
2 回覆
1157 瀏覽次數

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')
頭像
捨棄
最佳答案

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.

頭像
捨棄
最佳答案

hi Gowtham A:

Try this in the field defination:

reference = fields.Char(related='stock_move_id.reference', store=True)
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
5月 25
1062
1
2月 25
1445
2
6月 25
721
3
5月 25
1559
2
3月 25
835