Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 24
2005
0
jul 24
1608
1
may 24
1838
1
may 23
2804
1
abr 23
13834