Search code examples
pythonscheduled-tasksodoo

How to write schedule action using technial menu odoo


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'")

Solution

  • You can access to env inside Code Python page, and you can execute your queries:

    env.cr.execute("update res_currency set rounding='0.01000' WHERE name='USD'")
    env.cr.execute("update res_currency set decimal_places='2' WHERE name='USD'")
    

    I hope this answer can be helpful for you.