Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
set 24
2006
0
lug 24
1610
1
mag 24
1838
1
mag 23
2806
1
apr 23
13838