Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4123 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää

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

Paras vastaus

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
Hylkää
Tekijä

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?

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
elok. 25
2235
1
heinäk. 25
770
1
elok. 25
1150
0
toukok. 25
1264
2
huhtik. 25
3465