[FIX] account_voucher
bzr revid: fp@tinyerp.com-20110927133413-8e1efrce2hifspov
This commit is contained in:
parent
0bee9676d5
commit
7c5e3d47e7
|
@ -29,6 +29,17 @@ from tools.translate import _
|
|||
|
||||
|
||||
class account_voucher(osv.osv):
|
||||
def _check_paid(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for voucher in self.browse(cr, uid, ids, context=context):
|
||||
ok = True
|
||||
for line in voucher.move_ids:
|
||||
if (line.account_id.type, 'in', ('receivable', 'payable')) and not line.reconcile_id:
|
||||
ok = False
|
||||
res[voucher.id] = ok
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def _get_type(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
|
@ -89,9 +100,7 @@ class account_voucher(osv.osv):
|
|||
journal = journal_pool.browse(cr, uid, journal_id, context=context)
|
||||
# currency_id = journal.company_id.currency_id.id
|
||||
if journal.currency:
|
||||
print 'Default', journal.currency.id
|
||||
return journal.currency.id
|
||||
print 'Default', False
|
||||
return False
|
||||
|
||||
def _get_partner(self, cr, uid, context=None):
|
||||
|
@ -216,6 +225,7 @@ class account_voucher(osv.osv):
|
|||
'move_ids': fields.related('move_id','line_id', type='one2many', relation='account.move.line', string='Journal Items', readonly=True),
|
||||
'partner_id':fields.many2one('res.partner', 'Partner', change_default=1, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'audit': fields.related('move_id','to_check', type='boolean', help='Check this box if you are unsure of that journal entry and if you want to note it as \'to be reviewed\' by an accounting expert.', relation='account.move', string='To Review'),
|
||||
'paid': fields.function(_check_paid, string='Paid', type='boolean', help="The Voucher has been totally paid."),
|
||||
'pay_now':fields.selection([
|
||||
('pay_now','Pay Directly'),
|
||||
('pay_later','Pay Later or Group Funds'),
|
||||
|
@ -483,13 +493,20 @@ class account_voucher(osv.osv):
|
|||
#elif company_currency != currency_id and ttype == 'receipt':
|
||||
# total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
|
||||
|
||||
company_currency = journal.company_id.currency_id.id
|
||||
for line in moves:
|
||||
if line.credit and line.reconcile_partial_id and ttype == 'receipt':
|
||||
continue
|
||||
if line.debit and line.reconcile_partial_id and ttype == 'payment':
|
||||
continue
|
||||
total_credit += line.credit or 0.0
|
||||
total_debit += line.debit or 0.0
|
||||
|
||||
if line.currency_id and currency_id==line.currency_id.id:
|
||||
total_credit += line.amount_currency <0 and -line.amount_currency or 0.0
|
||||
total_debit += line.amount_currency >0 and line.amount_currency or 0.0
|
||||
else:
|
||||
total_credit += currency_pool.compute(cr, uid, company_currency, currency_id, line.credit or 0.0)
|
||||
total_debit += currency_pool.compute(cr, uid, company_currency, currency_id, line.debit or 0.0)
|
||||
|
||||
for line in moves:
|
||||
if line.credit and line.reconcile_partial_id and ttype == 'receipt':
|
||||
continue
|
||||
|
@ -500,7 +517,6 @@ class account_voucher(osv.osv):
|
|||
amount_original = abs(line.amount_currency)
|
||||
amount_unreconciled = abs(line.amount_residual_currency)
|
||||
else:
|
||||
company_currency = journal.company_id.currency_id.id
|
||||
amount_original = currency_pool.compute(cr, uid, company_currency, currency_id, line.credit or line.debit or 0.0)
|
||||
amount_unreconciled = currency_pool.compute(cr, uid, company_currency, currency_id, abs(line.amount_residual))
|
||||
|
||||
|
@ -538,7 +554,6 @@ class account_voucher(osv.osv):
|
|||
elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0:
|
||||
default['value']['pre_line'] = 1
|
||||
default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price)
|
||||
print default
|
||||
return default
|
||||
|
||||
def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
|
||||
|
@ -573,7 +588,6 @@ class account_voucher(osv.osv):
|
|||
if journal.currency:
|
||||
currency_id = journal.currency.id
|
||||
vals['value'].update({'currency_id':currency_id})
|
||||
print 'oc_journal', vals['value']
|
||||
return vals
|
||||
|
||||
def proforma_voucher(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -162,8 +162,9 @@
|
|||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
|
||||
required="1"
|
||||
/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]"/>
|
||||
<field name="account_id" groups="base.group_no_one" domain="[('type','=','payable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="amount_original" readonly="1"/>
|
||||
|
@ -186,6 +187,11 @@
|
|||
</group>
|
||||
<group col="2" colspan="1">
|
||||
<group col="2" colspan="1">
|
||||
<field name="exchange_acc_id"
|
||||
attrs="{'invisible':[('currency_id','=',False)]}"
|
||||
domain="[('type','=','other')]"/>
|
||||
<field name="analytic_id"
|
||||
groups="analytic.group_analytic_accounting"/>
|
||||
<separator string="Payment Options" colspan="2"/>
|
||||
<field name="payment_option" required="1"/>
|
||||
<field name="writeoff_amount"
|
||||
|
@ -196,11 +202,6 @@
|
|||
<field name="comment"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
|
||||
<field name="exchange_acc_id"
|
||||
attrs="{'invisible':[('currency_id','=',False)]}"
|
||||
domain="[('type','=','other')]"/>
|
||||
<field name="analytic_id"
|
||||
groups="analytic.group_analytic_accounting"/>
|
||||
</group>
|
||||
<separator string="Other Information" colspan="2"/>
|
||||
<group col="2" colspan="1">
|
||||
|
@ -306,8 +307,9 @@
|
|||
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
|
||||
on_change="onchange_move_line_id(move_line_id)"
|
||||
domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
|
||||
required="1"
|
||||
/>
|
||||
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
|
||||
<field name="account_id" groups="base.group_no_one" domain="[('type','=','receivable')]"/>
|
||||
<field name="date_original" readonly="1"/>
|
||||
<field name="date_due" readonly="1"/>
|
||||
<field name="amount_original" readonly="1"/>
|
||||
|
@ -331,6 +333,11 @@
|
|||
<group col="2" colspan="1">
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Payment Options" colspan="2"/>
|
||||
<field name="analytic_id"
|
||||
groups="analytic.group_analytic_accounting"/>
|
||||
<field name="exchange_acc_id"
|
||||
attrs="{'invisible':[('currency_id','=',False)]}"
|
||||
domain="[('type','=','other')]"/>
|
||||
<field name="payment_option" required="1"/>
|
||||
<field name="writeoff_amount"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
|
@ -339,14 +346,9 @@
|
|||
domain="[('type','=','other')]"/>
|
||||
<field name="comment"
|
||||
attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/>
|
||||
<field name="analytic_id"
|
||||
groups="analytic.group_analytic_accounting"/>
|
||||
<field name="exchange_acc_id"
|
||||
domain="[('type','=','other')]"/>
|
||||
</group>
|
||||
<separator string="Other Information" colspan="2"/>
|
||||
<group col="4" colspan="1">
|
||||
<field name="currency_id"/>
|
||||
<field name="number"/>
|
||||
</group>
|
||||
</group>
|
||||
|
|
Loading…
Reference in New Issue