Skip to Content
Menu
This question has been flagged

Hi everyone, hope you're having an excellent day and would be awesome if someone have a tip, solution or comment of the following. [Odoo Sh v16]




I want to update 'x_check_multidivisa" a character field.


In case of computed field, here's the code:

for order in self:
  if order.x_studio_f_subtotal_mxn > 1.00 and order.x_studio_f_subtotal_usd > 1.00:
    order.write({'x_check_multidivisa': 'Cotización Multi-Divisa'})
  elif order.x_studio_f_subtotal_mxn == 1.00 and order.x_studio_f_subtotal_usd > 1.00:
    order.write({'x_check_multidivisa': 'Cotización USD'})
  elif order.x_studio_f_subtotal_usd == 1.00 and order.x_studio_f_subtotal_mxn > 1.00:
    order.write({'x_check_multidivisa': 'Cotización MXN'})
  elif order.x_studio_f_subtotal_mxn == 1.00 and order.x_studio_f_subtotal_usd == 1.00:
    order.write({'x_check_multidivisa': 'Cotización Nueva'}) 
  else:
    pass

The ERROR encountering is when I add a Client/Partner the field is updated to 'Cotización Nueva' but then I add a product and the computing fails tu update itself.

Both 'subtotl' update when the quotation is saved.

____________________

In case of automated action, same code, but it doesn't write any text in the field 'x_check_multidivisa' I want to update the fiel when the fields 'subtotal' update

________________________

The final objective after this is to evaluate 'x_check_multidivsa' against 'pricelist_id

So that if 'x_check_multidivisa' = Cotización MXN and 'pricelist_id' is List Price MXN to let the user confirm the quotation

elif  'x_check_multidivisa' = Cotización USD and 'pricelist_id' is List Price USD to let the user confirm the quotation

elif 'x_check_multidivisa' = Cotización Nueva or Cotización Multidivisa and 'pricelist_id' is List Price USD or MXN to raise UserError for trying to sell with two currencies.


Hope someone of the community helps or give any tips, best regards.

Avatar
Discard
Related Posts Replies Views Activity
1
Sep 24
2007
0
Jul 24
1611
1
May 24
1839
1
May 23
2807
1
Apr 23
13843