What's wrong with my code ?
Requested:
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
What i currently have (not working):
@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
It depends on the type of A
, B
, C
, and X
. I am considering them of type string 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