Reputation: 1137
I need to do an addition if the type_In
== "In" and a subtraction if the type_In
== "Out"
the sum
attribute does just the addition
<field name="type_In"/>
<field name="Amount_In" sum="Amount total"/>
Upvotes: 1
Views: 174
Reputation: 14751
I don't think there is a better why only if you are good in javascipt.
try to add a compute field.
Amount_value = fields....(compute="_get_amout_value") # same field type as Amount_In
@api.depends('Amount_In')
def get_amout_value(self):
for rec in self:
if rec.type_In == "In":
rec.Amount_value = rec.Amount_In
else :
rec.Amount_value = rec.Amount_In * -1
and if the tree:
<field name="type_In"/>
<field name="Amount_value" sum="Amount total"/>
Upvotes: 1