29
30
from osv import fields, osv
31
32
class account_journal_simulation(osv.osv):
32
_name = "account.journal.simulation"
33
_description = "Simulation level"
35
'name': fields.char('Simulation name', size=32, required=True),
36
'code': fields.char('Simulation code', size=8, required=True),
39
('code_uniq', 'unique (code)', 'The code of the simulation must be unique !')
33
_name = "account.journal.simulation"
34
_description = "Simulation level"
36
'name': fields.char('Simulation name', size=32, required=True),
37
'code': fields.char('Simulation code', size=8, required=True),
40
('code_uniq', 'unique (code)', 'The code of the simulation must be unique !')
42
43
account_journal_simulation()
44
45
def _state_simul_get(self, cr, uid, context={}):
45
obj = self.pool.get('account.journal.simulation')
46
ids = obj.search(cr, uid, [])
47
res = obj.read(cr, uid, ids, ['code', 'name'], context)
48
return [('valid','Base')]+ [(r['code'], r['name']) for r in res]
46
obj = self.pool.get('account.journal.simulation')
47
ids = obj.search(cr, uid, [])
48
res = obj.read(cr, uid, ids, ['code', 'name'], context)
49
return [('valid','Base')]+ [(r['code'], r['name']) for r in res]
50
51
class account_journal(osv.osv):
51
_inherit = "account.journal"
53
'state': fields.selection(_state_simul_get, 'Status', required=True),
54
'parent_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_src_id', 'journal_dest_id', 'Childs journal'),
55
'child_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_dest_id', 'journal_src_id', 'Parent journal'),
58
'state': lambda self,cr,uid,context: 'valid'
52
_inherit = "account.journal"
54
'state': fields.selection(_state_simul_get, 'Status', required=True),
55
'parent_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_src_id', 'journal_dest_id', 'Childs journal'),
56
'child_ids': fields.many2many('account.journal', 'account_journal_simulation_rel', 'journal_dest_id', 'journal_src_id', 'Parent journal'),
59
'state': lambda self,cr,uid,context: 'valid'
62
63
class account_move_line(osv.osv):
63
_inherit = "account.move.line"
64
def search_not_run(self, cr, uid, crit, offset=0, limit=None, order=None, context={}):
65
if not 'fiscalyear' in context:
66
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
69
if c[0]=='journal_id':
72
if 'journal_id' in context:
76
for state in context.get('journal_state', []):
78
cr.execute("select id from account_journal where state in ('valid'"+plus+")")
79
crit.append(('journal_id', 'in', map(lambda x: x[0], cr.fetchall())))
80
res = super(account_move_line, self).search(cr, uid, crit, offset, limit, order, context)
64
_inherit = "account.move.line"
65
def search_not_run(self, cr, uid, crit, offset=0, limit=None, order=None, context={}):
66
if not 'fiscalyear' in context:
67
context['fiscalyear'] = self.pool.get('account.fiscalyear').find(cr, uid)
70
if c[0]=='journal_id':
73
if 'journal_id' in context:
77
for state in context.get('journal_state', []):
79
cr.execute("select id from account_journal where state in ('valid'"+plus+")")
80
crit.append(('journal_id', 'in', map(lambda x: x[0], cr.fetchall())))
81
res = super(account_move_line, self).search(cr, uid, crit, offset, limit, order, context)
83
def _query_get(self, cr, uid, obj='l', context={}):
84
res = super(account_move_line, self)._query_get(cr, uid, obj, context)
85
if context.get('journal_state', []):
86
plus = " and (l.journal_id in (select id from account_journal where state in ('valid', "+','.join(map(lambda x: "'"+x+"'", context['journal_state']))+")))"
88
plus = " and (l.journal_id in (select id from account_journal where state='valid'))"
84
def _query_get(self, cr, uid, obj='l', context={}):
85
res = super(account_move_line, self)._query_get(cr, uid, obj, context)
86
if context.get('journal_state', []):
87
plus = " and ("+obj+".journal_id in (select id from account_journal where state in ('valid', "+','.join(map(lambda x: "'"+x+"'", context['journal_state']))+")))"
89
plus = " and ("+obj+".journal_id in (select id from account_journal where state='valid'))"
90
91
account_move_line()
92
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: