return False
def _get_payment_rate_currency(self, cr, uid, context=None):
- '''
+ """
Return the default value for field payment_rate_currency_id: the currency of the journal
if there is one, otherwise the currency of the user's company
- '''
+ """
if context is None: context = {}
journal_pool = self.pool.get('account.journal')
journal_id = context.get('journal_id', False)
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
mod_obj = self.pool.get('ir.model.data')
if context is None: context = {}
- if not view_id and context.get('invoice_type', False):
- if context.get('invoice_type', False) in ('out_invoice', 'out_refund'):
- result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
- else:
- result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form')
- result = result and result[1] or False
- view_id = result
- if not view_id and view_type == 'form' and context.get('line_type', False):
- if context.get('line_type', False) == 'customer':
- result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
- else:
- result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form')
- result = result and result[1] or False
- view_id = result
+
+ if view_type == 'form':
+ if not view_id and context.get('invoice_type'):
+ if context.get('invoice_type') in ('out_invoice', 'out_refund'):
+ result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
+ else:
+ result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form')
+ result = result and result[1] or False
+ view_id = result
+ if not view_id and context.get('line_type'):
+ if context.get('line_type') == 'customer':
+ result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
+ else:
+ result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form')
+ result = result and result[1] or False
+ view_id = result
res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
doc = etree.XML(res['arch'])
line_ids = resolve_o2m_operations(cr, uid, line_pool, line_ids, ["amount"], context)
- total = 0.0
- total_tax = 0.0
for line in line_ids:
line_amount = 0.0
line_amount = line.get('amount',0.0)
tr_type = 'purchase'
else:
if not journal.default_credit_account_id or not journal.default_debit_account_id:
- raise osv.except_osv(_('Error !'), _('Please define default credit/debit account on the %s !') % (journal.name))
+ raise osv.except_osv(_('Error !'), _('Please define default credit/debit accounts on the journal "%s" !') % (journal.name))
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
tr_type = 'receipt'
default['value']['account_id'] = account_id
default['value']['type'] = ttype or tr_type
- vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, company_id, context)
+ vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, time.strftime('%Y-%m-%d'), price, ttype, company_id, context)
default['value'].update(vals.get('value'))
return default
return vals
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context=None):
+ if not journal_id:
+ return {}
res = self.recompute_voucher_lines(cr, uid, ids, partner_id, journal_id, amount, currency_id, ttype, date, context=context)
vals = self.recompute_payment_rate(cr, uid, ids, res, currency_id, date, ttype, journal_id, amount, context=context)
for key in vals.keys():
:return: mapping between fieldname and value of account move line to create
:rtype: dict
'''
- move_line_obj = self.pool.get('account.move.line')
- currency_obj = self.pool.get('res.currency')
voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)
debit = credit = 0.0
# TODO: is there any other alternative then the voucher type ??
:return: mapping between fieldname and value of account move to create
:rtype: dict
'''
- move_obj = self.pool.get('account.move')
seq_obj = self.pool.get('ir.sequence')
voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)
if voucher_brw.number:
context = {}
move_line_obj = self.pool.get('account.move.line')
currency_obj = self.pool.get('res.currency')
+ tax_obj = self.pool.get('account.tax')
tot_line = line_total
rec_lst_ids = []
:return: mapping between fieldname and value of account move line to create
:rtype: dict
'''
- move_line_obj = self.pool.get('account.move.line')
currency_obj = self.pool.get('res.currency')
move_line = {}
context = {}
move_pool = self.pool.get('account.move')
move_line_pool = self.pool.get('account.move.line')
- currency_pool = self.pool.get('res.currency')
- tax_obj = self.pool.get('account.tax')
- seq_obj = self.pool.get('ir.sequence')
for voucher in self.browse(cr, uid, ids, context=context):
if voucher.move_id:
continue
# Create the writeoff line if needed
ml_writeoff = self.writeoff_move_line_get(cr, uid, voucher.id, line_total, move_id, name, company_currency, current_currency, context)
if ml_writeoff:
- ml_writeoff_id = move_line_pool.create(cr, uid, ml_writeoff, context)
+ move_line_pool.create(cr, uid, ml_writeoff, context)
# We post the voucher.
self.write(cr, uid, [voucher.id], {
'move_id': move_id,
'account_id':fields.many2one('account.account','Account', required=True),
'partner_id':fields.related('voucher_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'),
'untax_amount':fields.float('Untax Amount'),
- 'amount':fields.float('Allocation', digits_compute=dp.get_precision('Account')),
+ 'amount':fields.float('Amount', digits_compute=dp.get_precision('Account')),
'reconcile': fields.boolean('Full Reconcile'),
'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Dr/Cr'),
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'),