コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1419 ビュー

In my model, there is a compute field A, it is computed from 2 number fields B and C and 1 checkbox field D. My wanted compute code is like below:

 

Dependencies: B, C, D


Code:


for record in self:

    if record.D == True:

        record['A'] = record.B + record.C

    else:

        record['A'] = record.B

 

How do I write "if record.D == True" correctly? It doesn’t work now.

 

Thanks


アバター
破棄
最善の回答

This should work:

A = fields.Integer(compute="_compute_A")

@api.depends("B","C","D")
def _compute_A(self):
​for record in self:
​if record.D:
​record.A = record.B + record.C
​else:
record.a = record.B​

アバター
破棄
著作者

Hi, I know what happens now. When I click D, I have to click the 'Save manually' button for A to update.

関連投稿 返信 ビュー 活動
1
6月 25
15005
3
4月 25
5056
2
7月 24
1976
1
1月 24
1581
2
12月 23
1326