Odoo Help

Welcome!

This community 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.

0

The automated action doesn`t work

By
Konstantin
on 8/23/16, 5:23 PM 279 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)--
2983
| 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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