Skip to Content
Menu
This question has been flagged
2 Replies
3432 Views

Hello,

With studio, I have added a float field. I would like in Advanced Properties ‘compute’ a calculation. The calculation is working fine. But now, I want to add a condition ‘if contains’. I have tried with

  • if (record.taxes_id.__contains__(‘test')):
  • if record.taxes_id == “test":

The first one is not working and the second one is working if the field is for instance a char. However taxes_id is a M2M, which is the issue. 

- I have tried to add a [0] after taxes_id but the result is always false
- I have tried to add in a char field :  for record in self: record['x_studio_test2'] = record.taxes_id, in order to see the value. It’s for instance (account.tax(1,).
       - If I do the same with [0], I have still the same result.
       - If I do the same with if record.taxes_id == "account.tax(1,)": I have always false.

How could I do to have my condition that research inside the table ? The goal is to say if 1 (or something else like to a value in a table of a M2M(taxes_id)) that works. Means that is not always false...


Avatar
Discard
Best Answer

Hi, i have the same problem with a condition based on single bolean field :

ASS EXT : True

This is the calculated field :

for record in self:
if x_studio_assist_ext == TRUE:
record['x_studio_primes_ttc_12'] = record.x_studio_rc_cost + record.x_studio_mr_costs + record.x_studio_dm_cost + record.x_studio_cots_assist + record.x_studio_cond_cost + record.x_studio_pj_cost
else :
record['x_studio_primes_ttc_12'] = 0

and it do not work ...

Could you help me ?

Avatar
Discard
Best Answer

Hello

First set a boolean value, then loop through the many2many fields and do an OR operator like below:


Many2many field is - tax_ids
Boolean variable is - control_var


control_var = False

for i in record.tax_ids:
    control_var = control_var or i.name == 'test'

if control_var == True:
    //this will be your condition



Avatar
Discard
Related Posts Replies Views Activity
1
Feb 24
1171
1
Apr 24
1079
0
Feb 24
1361
0
Sep 21
1241
1
Apr 20
1741