Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
4119 Tampilan

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
Buang
Jawaban Terbai

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
Buang

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

Jawaban Terbai

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
Buang
Penulis

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?

Post Terkait Replies Tampilan Aktivitas
2
Agu 25
2235
1
Jul 25
770
1
Agu 25
1150
0
Mei 25
1264
2
Apr 25
3465