Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4126 Widoki

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


Awatar
Odrzuć
Najlepsza odpowiedź

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})


Awatar
Odrzuć

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

Najlepsza odpowiedź

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

Awatar
Odrzuć
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?

Powiązane posty Odpowiedzi Widoki Czynność
2
sie 25
2241
1
lip 25
776
1
sie 25
1150
0
maj 25
1265
2
kwi 25
3468