1
from osv import osv, fields
2
from datetime import datetime, timedelta
3
from tools.translate import _
5
class cpi_be_type(osv.osv):
9
'name':fields.char("Name", size=255),
10
'description':fields.char("Description", size=1024),
11
'entries':fields.one2many('cpi.be.entry','type_id', string='Entries')
16
class cpi_be_entry(osv.osv):
17
_name = 'cpi.be.entry'
19
_order = 'type_id, year desc, month desc, value'
21
def name_get(self, cr, uid, ids, context=None):
25
for entry in self.browse(cr, uid, ids, context=context):
26
result.append((entry.id,str(entry.year)+'/'+str(entry.month)))
30
'type_id':fields.many2one('cpi.be.type', string="Type"),
31
'year':fields.integer("Year"),
32
'month':fields.integer("Month"),
33
'value':fields.float("Value")
36
def _check_date(self, cr, uid, ids):
37
for cpi in self.browse(cr, uid, ids):
38
if cpi.month < 1 or cpi.month > 12:
42
_constraints = [(_check_date, 'Error: invalid month', ['month']), ]
45
('cpi_be_entry_unique', 'unique(type_id,year,month)', 'For the same type, year and month must be unique')
52
class cpi_be_update_wizard(osv.osv_memory):
53
_name = 'cpi.be.update.wizard'
55
def action_update(self, cr, uid, ids, context):
56
self.pool.get("scheduler.cpi_be").import_cpi_be_all(cr, uid, context=context)
57
return {'type': 'ir.actions.act_window_close'}
59
cpi_be_update_wizard()