如何在 python Odoo 中计算多个级别
How to compute multiple levels in python Odoo
我的代码有什么问题?
要求:
If A annd B are 0 show me result = A
If A and B are not 0 then continue
If C ID is 1 Do the equation
Else if it's another ID then show me result = A
Else of all just show A
我目前拥有的(不工作):
@api.depends('A', 'B','C')
def _compute_X(self):
for record in self:
if int(record.A or record.B) != 0 and int(record.C) == 1:
record.X = record.A / record.B
else:
record.X = record.A
这取决于 A
、B
、C
和 X
的类型。我正在考虑它们的字符串类型 class.
if int(record.A or record.B) != 0 and int(record.C) == 1:
record.X = str(int(record.A) / int(record.B))
# converting string to int while doing math operation and then converting the result to strting.
else:
record.X = record.A
我的代码有什么问题?
要求:
If A annd B are 0 show me result = A
If A and B are not 0 then continue
If C ID is 1 Do the equation
Else if it's another ID then show me result = A
Else of all just show A
我目前拥有的(不工作):
@api.depends('A', 'B','C')
def _compute_X(self):
for record in self:
if int(record.A or record.B) != 0 and int(record.C) == 1:
record.X = record.A / record.B
else:
record.X = record.A
这取决于 A
、B
、C
和 X
的类型。我正在考虑它们的字符串类型 class.
if int(record.A or record.B) != 0 and int(record.C) == 1:
record.X = str(int(record.A) / int(record.B))
# converting string to int while doing math operation and then converting the result to strting.
else:
record.X = record.A