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

hi all,

can i add a Many2one field in a model which will not save data in the database like computed field or related field where we can define store=False or store=True? if yes, how? 

OR

any other idea to have Many2one field which will not store data in database?

regards


頭像
捨棄
最佳答案

you can define many2one field as non stored field like

order_id = fields.Many2one('sale.order', compute="_compute_order_id")

def _compute_order_id(self):
for record in self:
# get/compute order_id from other field or based on your business logic
record.order_id = 2
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
4月 23
2873
2
2月 25
40663
2
11月 22
2919
1
2月 22
7938
2
12月 21
4209