Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1254 Lượt xem

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')
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

hi Gowtham A:

Try this in the field defination:

reference = fields.Char(related='stock_move_id.reference', store=True)
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 5 25
1172
1
thg 2 25
1588
2
thg 6 25
856
3
thg 5 25
1724
2
thg 3 25
944