Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
4125 Vistas

I want to write schedule action using front end.I mean I go to setting--> techinal-->schedule action and create and I want to add the following code.How can I do that?

@api.model
    def fix_currency(self):
        fix = self.env.cr.execute("update res_currency set rounding='0.01000' WHERE name='USD'")
        fix = self.env.cr.execute("update res_currency set decimal_places='2' WHERE name='USD'")


Avatar
Descartar
Mejor respuesta

Help with Python expressions

Various fields may use Python code or Python expressions. The following variables can be used:

  • env: Odoo Environment on which the action is triggered
  • model: Odoo Model of the record on which the action is triggered; is a void recordset
  • record: record on which the action is triggered; may be be void
  • records: recordset of all records on which the action is triggered in multi mode; may be void
  • time, datetime, dateutil, timezone: useful Python libraries
  • log(message, level='info'):logging function to record debug information in ir.logging table
  • UserError: Warning Exception to use with raise
  • To return an action, assign: action = {...}

Example of Python code

partner_name = record.name + '_code'
env['res.partner'].create({'name': partner_name})


Avatar
Descartar

You should never use the database cursor directly when the ORM can do the same thing! By doing so you are bypassing all the ORM features, possibly the automated behaviours like translations, invalidation of fields, active, access rights and so on.

https://www.odoo.com/documentation/15.0/developer/reference/backend/security.html?highlight=bypass#bypassing-the-orm

Mejor respuesta

Hello GGWP,

Please find below link it may help you,

https://www.cybrosys.com/blog/scheduled-actions-in-odoo-14

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Descartar
Autor

Hello Jainesh,
Thanks for your answers. I know how to do using custom module but I just want to add in front without using any custom module.Is it possible?

Publicaciones relacionadas Respuestas Vistas Actividad
2
ago 25
2241
1
jul 25
776
1
ago 25
1150
0
may 25
1265
2
abr 25
3468