← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-bug-742283-ara into lp:openobject-addons

 

Ashvin Rathod (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-742283-ara into lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #742283 in OpenERP Addons: "Can pay Sales Receipt multiple times"
  https://bugs.launchpad.net/openobject-addons/+bug/742283

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-742283-ara/+merge/55722

Hello,

Fix: #742283 Can pay Sales Receipt multiple times

Thanks,
ara
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-742283-ara/+merge/55722
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-742283-ara.
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py	2011-03-19 09:35:42 +0000
+++ account_voucher/account_voucher.py	2011-03-31 10:33:38 +0000
@@ -142,6 +142,21 @@
             res['arch'] = etree.tostring(doc)
         return res
 
+    def _check_paid(self, cr, uid, ids, name, args, context=None):
+        res = {}
+        for id in ids:
+            res[id] = self.test_paid(cr, uid, [id], context=context)
+        return res
+
+    def test_paid(self, cr, uid, ids, context):
+        recs = []
+        paid = False
+        for voucher in self.browse(cr, uid, ids, context=context):
+            for line in voucher.move_ids:
+                if line.reconcile_id and (line.account_id.user_type.name, 'in', ('receivable', 'payable')):
+                    paid = True
+        return paid
+
     def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount):
         debit = credit = 0.0
         for l in line_dr_ids:
@@ -227,6 +242,7 @@
         'comment': fields.char('Write-Off Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
         'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}),
         'writeoff_amount': fields.function(_get_writeoff_amount, method=True, string='Write-Off Amount', type='float', readonly=True),
+        'paid': fields.function(_check_paid, method=True, string='Paid', type='boolean', help="The Voucher has been totally paid."),
     }
     _defaults = {
         'period_id': _get_period,

=== modified file 'account_voucher/voucher_sales_purchase_view.xml'
--- account_voucher/voucher_sales_purchase_view.xml	2011-03-17 09:38:22 +0000
+++ account_voucher/voucher_sales_purchase_view.xml	2011-03-31 10:33:38 +0000
@@ -130,6 +130,7 @@
                                          attrs="{'invisible':[('pay_now','!=','pay_now')]}"
                                     />
                                     <field name="date_due" attrs="{'invisible':[('pay_now','=','pay_now')]}"/>
+                                    <field name="paid"/>
                                 </group>
                                 <group col="4" colspan="1">
                                     <separator string="Total" colspan="4"/>
@@ -166,7 +167,7 @@
                         <button name="cancel_voucher" string="Cancel" states="draft,proforma"  icon="gtk-cancel"/>
                         <button name="cancel_voucher" string="Cancel" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to confirm this record ?"/>
                         <button name="proforma_voucher" string="Validate" states="draft" icon="gtk-go-forward"/>
-                        <group attrs="{'invisible':[('state','!=','posted')]}">
+                        <group attrs="{'invisible':['|', ('state','!=','posted'), ('paid','=',True)]}">
                            <button icon="terp-dolar_ok!" name="%(act_pay_voucher)d" context="{'narration':narration, 'title':'Customer Payment', 'type':'receipt', 'partner_id':partner_id, 'reference':reference, 'amount':amount}" type="action" string="Pay" attrs="{'invisible':[('pay_now','=','pay_now')]}"/>
                         </group>
                         <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>
@@ -250,6 +251,7 @@
                                 <group col="2" colspan="1">
                                     <separator string="Payment Terms" colspan="2"/>
                                     <field name="date_due"/>
+                                    <field name="paid"/>
                                 </group>
                                 <group col="4" colspan="1">
                                     <separator string="Total" colspan="4"/>
@@ -285,7 +287,7 @@
                         <field name="state"/>
                         <button name="cancel_voucher" string="Cancel" states="draft,proforma"  icon="gtk-cancel"/>
                         <button name="cancel_voucher" string="Cancel" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to confirm this record ?"/>
-                        <group attrs="{'invisible':[('state','!=','posted')]}">
+                        <group attrs="{'invisible':['|', ('state','!=','posted'), ('paid','=',True)]}">
                             <button icon="terp-dolar_ok!" name="%(act_pay_bills)d" context="{'narration':narration, 'title':'Bill Payment', 'type':'payment', 'partner_id': partner_id, 'reference':reference}" type="action" string="Pay Bill" attrs="{'invisible':[('pay_now','=','pay_now')]}"/>
                         </group>
                         <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>


Follow ups