Odoo Help

0

OpenERP Cron with field increment?

By
Assim Al-Marhuby
on 10/6/13, 4:55 PM 1,701 views

How can I create a cron job that is executed every end of the year, and all it does is increment a field by 1. That's all

Thanks.

0
odoo.ma by IBS Group
On 10/6/13, 5:36 PM

You can do this by creating a scheduler, go to Settings > Technical > Scheduler > Scheduled Actions

Check the existing scheduled actions to get an idea how it works.

To increment either do it by code with a read/increment/write operation, or use a sequence.

I did that, but how do I do the increment? Could you please give me an example code that shows you getting a value from a column and incrementing it.

Assim Al-Marhuby
on 10/6/13, 5:43 PM

Get the value, increment it with python and then save it again.

odoo.ma by IBS Group
on 10/6/13, 5:48 PM

You can find the functions to read and write in this page https://doc.openerp.com/v6.1/developer/03_modules_2/

odoo.ma by IBS Group
on 10/6/13, 5:50 PM

The relevant functions are browse() and write()

odoo.ma by IBS Group
on 10/6/13, 5:51 PM

A good example is the currency_rate_update module, which runs the "run_currency_update" function once a day. Download that module and look at the code. You'll have to 1. write a python module 2. install your module 3. create a new Scheduled Action referencing your new module and the Increment function (method) you want to run. You should be 90% of the way there by referencing the currency_rate_update module (I think you really only need to reference the class Currency_rate_update, you can probably ignore the rest)

Michael Watchorn
on 11/12/13, 1:45 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 10/6/13, 4:55 PM
Seen: 1701 times
Last updated: 3/16/15, 8:10 AM