total = 0.0
total_tax = 0.0
-
for line in line_ids:
line_amount = 0.0
- line_amount = line[2].get('amount')
+ line_amount = line[2] and line[2].get('amount',0.0) or 0.0
voucher_line_ids += [line[1]]
voucher_total += line_amount
def proforma_voucher(self, cr, uid, ids, context=None):
self.action_move_line_create(cr, uid, ids, context=context)
return True
+ #return {'type' : 'ir.actions.act_window_close' }
+
def action_cancel_draft(self, cr, uid, ids, context={}):
wf_service = netsvc.LocalService("workflow")
move_pool = self.pool.get('account.move')
move_line_pool = self.pool.get('account.move.line')
currency_pool = self.pool.get('res.currency')
- bank_st_line_obj = self.pool.get('account.bank.statement.line')
tax_obj = self.pool.get('account.tax')
for inv in self.browse(cr, uid, ids):
if inv.move_id:
'period_id': inv.period_id and inv.period_id.id or False
}
move_id = move_pool.create(cr, uid, move)
- line_bank_ids = bank_st_line_obj.search(cr, uid, [('voucher_id', '=', inv.id)], context=context)
- if line_bank_ids:
- bank_st_line_obj.write(cr, uid, line_bank_ids, {
- 'move_ids': [(4, move_id, False)]
- })
#create the first line manually
company_currency = inv.journal_id.company_id.currency_id.id
credit = 0.0
move_line = {
- 'name':inv.name or '/',
- 'debit':debit,
- 'credit':credit,
- 'account_id':inv.account_id.id,
- 'move_id':move_id,
- 'journal_id':inv.journal_id.id,
- 'period_id':inv.period_id.id,
- 'partner_id':inv.partner_id.id,
- 'currency_id':inv.currency_id.id,
- 'amount_currency':inv.amount,
- 'date':inv.date,
- 'date_maturity':inv.date_due
+ 'name': inv.name or '/',
+ 'debit': debit,
+ 'credit': credit,
+ 'account_id': inv.account_id.id,
+ 'move_id': move_id,
+ 'journal_id': inv.journal_id.id,
+ 'period_id': inv.period_id.id,
+ 'partner_id': inv.partner_id.id,
+ 'currency_id': inv.currency_id.id,
+ 'amount_currency': inv.amount,
+ 'date': inv.date,
+ 'date_maturity': inv.date_due
}
if (debit == 0.0 or credit == 0.0 or debit+credit > 0) and (debit > 0.0 or credit > 0.0):
if not line.amount:
continue
amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, line.amount)
-
move_line = {
- 'journal_id':inv.journal_id.id,
- 'period_id':inv.period_id.id,
- 'name':line.name and line.name or '/',
- 'account_id':line.account_id.id,
- 'move_id':move_id,
- 'partner_id':inv.partner_id.id,
- 'currency_id':inv.currency_id.id,
- 'amount_currency':line.amount,
- 'analytic_account_id':line.account_analytic_id and line.account_analytic_id.id or False,
- 'quantity':1,
- 'credit':0.0,
- 'debit':0.0,
- 'date':inv.date
+ 'journal_id': inv.journal_id.id,
+ 'period_id': inv.period_id.id,
+ 'name': line.name and line.name or '/',
+ 'account_id': line.account_id.id,
+ 'move_id': move_id,
+ 'partner_id': inv.partner_id.id,
+ 'currency_id': inv.currency_id.id,
+ 'amount_currency': line.amount,
+ 'analytic_account_id': line.account_analytic_id and line.account_analytic_id.id or False,
+ 'quantity': 1,
+ 'credit': 0.0,
+ 'debit': 0.0,
+ 'date': inv.date
}
if amount < 0:
amount = -amount
if inv.tax_id and inv.type in ('sale', 'purchase'):
move_line.update({
- 'account_tax_id':inv.tax_id.id,
+ 'account_tax_id': inv.tax_id.id,
})
if move_line.get('account_tax_id', False):
tax_data = tax_obj.browse(cr, uid, [move_line['account_tax_id']], context=context)[0]
def copy(self, cr, uid, id, default={}, context=None):
default.update({
- 'state':'draft',
- 'number':False,
- 'move_id':False,
- 'line_cr_ids':False,
- 'line_dr_ids':False,
- 'reference':False
+ 'state': 'draft',
+ 'number': False,
+ 'move_id': False,
+ 'line_cr_ids': False,
+ 'line_dr_ids': False,
+ 'reference': False
})
if 'date' not in default:
default['date'] = time.strftime('%Y-%m-%d')
'company_id': fields.related('voucher_id','company_id', relation='res.company', string='Company', store=True),
}
_defaults = {
- 'name': lambda *a: ''
+ 'name': ''
}
def onchange_move_line_id(self, cr, user, ids, move_line_id, context={}):
move_line = move_line_pool.browse(cr, user, move_line_id, context=context)
if move_line.credit:
ttype = 'dr'
-# amount = move_line.credit
else:
ttype = 'cr'
account_id = move_line.account_id.id
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None):
voucher_obj = self.pool.get('account.voucher')
wf_service = netsvc.LocalService("workflow")
- st_line = self.pool.get('account.bank.statement.line').browse(cr, uid, st_line_id, context=context)
+ bank_st_line_obj = self.pool.get('account.bank.statement.line')
+ st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context)
if st_line.voucher_id:
voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number}, context=context)
if st_line.voucher_id.state == 'cancel':
voucher_obj.action_cancel_draft(cr, uid, [st_line.voucher_id.id], context=context)
wf_service.trg_validate(uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr)
- return self.pool.get('account.move.line').write(cr, uid, [x.id for x in st_line.voucher_id.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
+
+ v = voucher_obj.browse(cr, uid, st_line.voucher_id.id, context=context)
+ bank_st_line_obj.write(cr, uid, [st_line_id], {
+ 'move_ids': [(4, v.move_id.id, False)]
+ })
+
+ return self.pool.get('account.move.line').write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
account_bank_statement()
account_bank_statement_line()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:=======