Skip to Content
Menu
This question has been flagged
2 Replies
3264 Views

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
Discard
Best Answer

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
Discard

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

Best Answer

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
Discard
Author

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?

Related Posts Replies Views Activity
2
Nov 24
262
1
Oct 24
328
4
Oct 24
324
2
Oct 24
361
2
Dec 24
661