Odoo Help

0

The automated action doesn`t work

By
Konstantin
on 8/23/16, 5:23 PM 544 views

I have py script

# -*- coding: utf-8 -*-
from openerp import models, fields, api
from datetime import datetime, date
from openerp.tools.translate import _
class AddPriority(models.Model):
_name = 'account.invoice.priority'
_description = "Descriptions for new priority"
name = fields.Char('Name', size = 26, required=True, help='Name for new priority')
descript = fields.Text( 'Description', help='Descriptions for new priority')
class My_invoices(models.Model):
_inherit = 'account.invoice'
priority = fields.Many2one('account.invoice.priority', string='Priority', required=True, help='Select Priority', store=True)
delay = fields.Integer(string = 'Delay', readonly = True, help = 'Day Delay', compute='_delay', store=True )
@api.multi
@api.depends('date_due','delay')
def _delay(self):
if self.date_due != False:
day_delay = datetime.strptime(self.date_due, '%Y-%m-%d').date()
day_now = date.today()
day = str(day_delay - day_now)
day = day.replace('0:00:00','')
if 'day' in day:
day = day.replace(' day, ','')
if 'days'in day:
day = day.replace(' days, ','')
if day =='':
day = 0
else:
day = int(day)
self.delay = day
def my_up(self, cr, uid, context= None):
scheduler_line_obj = self.pool.get('account.invoice')
scheduler_line_ids = self.pool.get('account.invoice').search(cr, uid, [])
for scheduler_line_id in scheduler_line_ids :
scheduler_line =scheduler_line_obj.browse(cr, uid,scheduler_line_id ,context=context)
delay = scheduler_line.delay
scheduler_line_obj.write(cr, uid, scheduler_line_id, {'delay': (delay -1)}, context=context)
and xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
 <record id="update_date_action" model="ir.cron">
<field name="name">Date for invoice priority</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'My_invoices'" name="model"/>
<field eval="'my_up'" name="function"/>
</record>
 </data>
</openerp>


Cron was created but dont work. Why does nothing happen? where is my mistake? 

0

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
4440
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 8/23/16, 5:49 PM

Maybe if you provide your traceback, it will help us to help you :)

But in any case 'My_invoices' is not a model... it should probably be something like 'account.invoice' so <field name='model' ref='model_account_invoice'/> or <field name='model'>account.invoice</field>

0
Konstantin
On 8/24/16, 2:17 AM

Thanks Jérémy Kersten really inheritance model is necessary to specify the parent. Sorry for my English

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

2 follower(s)

Stats

Asked: 8/23/16, 5:23 PM
Seen: 544 times
Last updated: 8/24/16, 2:17 AM