28
29
def post(self, cr, uid, ids, context=None):
30
31
print >> sys.stderr,'post move context',context
32
32
journal_id = context.get('journal_id')
34
if 'period_id' in context:
35
period_id = [context.get('period_id')]
36
print >> sys.stderr,'post move period_id', period_id
33
37
invoice_obj = context.get('invoice')
35
39
journal_id = invoice_obj.journal_id.id
55
59
if jour.create_sequence == 'create_fy' :
56
60
fy_seq_obj = self.pool.get('account.sequence.fiscalyear')
57
61
period_obj = self.pool.get('account.period')
58
period_ids = context.get('period_id')
60
63
print >> sys.stderr,'per_id A'
61
64
period_id = invoice_obj.period_id.id
62
65
print >> sys.stderr,'per_id B', period_id
66
69
print >> sys.stderr,'per_id D', period_id
68
71
for period in period_obj.browse(cr, uid, period_id):
69
fy_id = period.fiscalyear_id.id
70
fy_code = period.fiscalyear_id.code
71
print >> sys.stderr,'fy_id', fy_id
72
print >> sys.stderr,'fy_id', period
73
fy_id = period.fiscalyear_id.id
74
fy_code = period.fiscalyear_id.code
75
print >> sys.stderr,'fy_id a', fy_id
72
76
fy_seq = fy_seq_obj.search(cr, uid, [('fiscalyear_id','=', fy_id),('sequence_main_id','=',main_seq_id)])
73
77
print >> sys.stderr,'fy_seq_id', fy_seq
89
93
print >> sys.stderr,'fy_rel',fy_rel, prefix
90
94
fy_seq_obj.create(cr, uid, fy_rel)
92
97
return super(account_move, self).post(cr, uid, ids, context)
95
def post_gk(self, cr, uid, ids, context=None):
96
if context is None : context = {}
97
invoice = context.get('invoice', False)
98
valid_move_ids = self.validate(cr, uid, ids, context)
99
if not valid_move_ids:
100
raise osv.except_osv \
101
( _('Integrity Error !')
102
, _('You cannot validate a non-balanced entry!\nMake sure you have configured Payment Term properly !\nIt should contain at least one Payment Term Line with type "Balance" !')
104
seq_obj = self.pool.get('ir.sequence')
105
jou_obj = self.pool.get('account.journal')
106
for move in self.browse(cr, uid, valid_move_ids, context=context):
109
journal = move.journal_id
110
if invoice and invoice.internal_number:
111
new_name = invoice.internal_number
113
if journal.sequence_id:
115
{ 'fiscalyear_id' : move.period_id.fiscalyear_id.id
116
, 'journal_id' : journal.id
118
new_name = seq_obj.next_by_id(cr, uid, journal.sequence_id.id, context=c)
121
{ 'name' : move.journal_id.name
122
, 'prefix' : "".join(w[0] for w in _(journal.name).split(' '))
124
, 'implementation' : 'no_gap'
126
new_id = seq_obj.create(cr, uid, values)
127
new_name = seq_obj._format(self, cr, uid, seq_obj.browse(cr, uid, new_id), context)
128
jou_obj.write(cr, uid, [journal_id.id], {'sequence_id' : new_id})
129
self.write(cr, uid, [move.id], {'name' : new_name})
130
self.write(cr, uid, valid_move_ids, {'state' : 'posted'})