openerp - automate actions with cron and the new api odoo -


i want automate action , here code i'm using:

<?xml version="1.0" encoding="utf-8"?> <openerp>     <data noupdate="1">         <record id="ir_cron_scheduler_demo_action" model="ir.cron">             <field name="name">demo scheduler</field>             <field name="user_id" ref="base.user_root"/>             <field name="interval_number">2</field>             <field name="interval_type">minutes</field>             <field name="numbercall">-1</field>             <field eval="false" name="doall"/>             <field eval="'note.admin'" name="model"/>             <field eval="'process_demo_scheduler_queue'" name="function"/>         </record>    </data> </openerp> 
@api.model def process_demo_scheduler_queue(self):     note in self.env['note.admin']:         if datetime.strptime(note.date, default_server_datetime_format).date() == datetime.now().date():             note.write({'is_visible': true}) 

what want set value is_visible on true when field note.date == current date

here log on server:

2016-05-25 01:20:17,658 3680 info test3 werkzeug: 127.0.0.1 - - [25/may/2016 01:20:17] "post /web/dataset/call_kw/note.admin/message_get_subscription_data http/1.1" 200 -

but not working!


solved:

@api.model def process_demo_scheduler_queue(self):     notes = self.search([('date', '=', fields.date.today())])     notes.write({'is_visible': true}) 

first have search notes in database, , second try use odoo's date logic:

@api.model def process_demo_scheduler_queue(self):     note in self.search([]):         if note.date == openerp.fields.date.context_today(self):             note.is_visible = true 

or maybe faster:

@api.model def process_demo_scheduler_queue(self):     notes = self.search([('date', '=', openerp.fields.date.context_today(self))])     notes.write({'is_visible': true}) 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -