[IMP] account_voucher: added a a column 'full reconcile' on the voucher lines
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Wed, 23 Nov 2011 14:32:22 +0000 (15:32 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Wed, 23 Nov 2011 14:32:22 +0000 (15:32 +0100)
bzr revid: qdp-launchpad@openerp.com-20111123143222-xuj8dfjw0ne85dfb

addons/account_voucher/account_voucher.py
addons/account_voucher/voucher_payment_receipt_view.xml

index b2c87a5..3c12db8 100644 (file)
@@ -600,6 +600,9 @@ class account_voucher(osv.osv):
                         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:
@@ -1165,6 +1168,7 @@ class account_voucher_line(osv.osv):
         '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'),
@@ -1175,9 +1179,22 @@ class account_voucher_line(osv.osv):
         '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
index 4adebed..6265abf 100644 (file)
                                     <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)">