rs['amount'] = amount
total_credit -= amount
+ if rs['amount_unreconciled'] == rs['amount']:
+ rs['reconcile'] = True
+
if rs['type'] == 'cr':
default['value']['line_cr_ids'].append(rs)
else:
'partner_id':fields.related('voucher_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'),
'untax_amount':fields.float('Untax Amount'),
'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'),
'move_line_id': fields.many2one('account.move.line', 'Journal Item'),
'company_id': fields.related('voucher_id','company_id', relation='res.company', type='many2one', string='Company', store=True, readonly=True),
}
_defaults = {
- 'name': ''
+ 'name': '',
+ 'reconcile': False,
}
+ def onchange_reconcile(self, cr, uid, ids, reconcile, amount, amount_unreconciled, context=None):
+ vals = { 'amount': 0.0}
+ if reconcile:
+ vals = { 'amount': amount_unreconciled}
+ return {'value': vals}
+
+ def onchange_amount(self, cr, uid, ids, amount, amount_unreconciled, context=None):
+ vals = {}
+ if amount:
+ vals['reconcile'] = (amount == amount_unreconciled)
+ return {'value': vals}
+
def onchange_move_line_id(self, cr, user, ids, move_line_id, context=None):
"""
Returns a dict that contains new values and context
<field name="date_due" readonly="1"/>
<field name="amount_original" readonly="1"/>
<field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
- <field name="amount" sum="Payment"/>
+ <field name="reconcile" on_change="onchange_reconcile(reconcile, amount, amount_unreconciled, context)"/>
+ <field name="amount" sum="Payment" on_change="onchange_amount(amount, amount_unreconciled, context)"/>
</tree>
</field>
<field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}">
<field name="date_due" readonly="1"/>
<field name="amount_original" readonly="1"/>
<field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
- <field name="amount" sum="Payment"/>
+ <field name="reconcile" on_change="onchange_reconcile(reconcile, amount, amount_unreconciled, context)"/>
+ <field name="amount" sum="Payment" on_change="onchange_amount(amount, amount_unreconciled, context)"/>
</tree>
</field>
<field name="line_dr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount, context)">