← Back to team overview

account-payment-team team mailing list archive

[Merge] lp:~pedro.baeza/account-payment/6.1-account_payment_extension_store into lp:account-payment

 

Pedro Manuel Baeza has proposed merging lp:~pedro.baeza/account-payment/6.1-account_payment_extension_store into lp:account-payment.

Requested reviews:
  Account Payment (account-payment-team)

For more details, see:
https://code.launchpad.net/~pedro.baeza/account-payment/6.1-account_payment_extension_store/+merge/203596

Methods for storing correctly the value amount_to_pay, that in 6.1 is stored, but not recomputed whenever its conditions changes, and for 7.0 is directly not stored, impacting on the performance on some operations.

Same for 7.0: https://code.launchpad.net/~pedro.baeza/account-payment/7.0-account_payment_extension_store/+merge/203594.
-- 
https://code.launchpad.net/~pedro.baeza/account-payment/6.1-account_payment_extension_store/+merge/203596
Your team Account Payment is requested to review the proposed merge of lp:~pedro.baeza/account-payment/6.1-account_payment_extension_store into lp:account-payment.
=== modified file 'account_payment_extension/account_move_line.py'
--- account_payment_extension/account_move_line.py	2013-09-12 11:01:19 +0000
+++ account_payment_extension/account_move_line.py	2014-01-28 17:14:41 +0000
@@ -183,13 +183,50 @@
                 return [('id', 'in', [x[0] for x in res])]
         return [('id','=','0')]
 
+    def _get_move_lines(self, cr, uid, ids, context=None):
+        result = {}
+        line_obj = self.pool.get('payment.line')
+        for line in line_obj.browse(cr, uid, ids, context=context):
+            result[line.move_line_id.id] = True
+            result[line.payment_move_id.id] = True
+        return result.keys()
+
+    def _get_move_lines_order(self, cr, uid, ids, context=None):
+        result = {}
+        order_obj = self.pool.get('payment.order')
+        for order in order_obj.browse(cr, uid, ids, context=context):
+            for line in order.line_ids:
+                result[line.move_line_id.id] = True
+                result[line.payment_move_id.id] = True
+        return result.keys()
+
+    def _get_reconcile(self, cr, uid, ids, context=None):
+        result = {}
+        reconcile_obj = self.pool.get('account.move.reconcile')
+        for reconcile in reconcile_obj.browse(cr, uid, ids, context=context):
+            for line in reconcile.line_id:
+                result[line.id] = True
+            for line in reconcile.line_partial_ids:
+                result[line.id] = True
+        return result.keys()
+
     _columns = {
         'invoice': fields.function(_invoice, method=True, string='Invoice',
             type='many2one', relation='account.invoice', fnct_search=_invoice_search),
         'received_check': fields.boolean('Received check', help="To write down that a check in paper support has been received, for example."),
         'partner_bank_id': fields.many2one('res.partner.bank','Bank Account'),
         'amount_to_pay' : fields.function(amount_to_pay, method=True, type='float', string='Amount to pay', fnct_search=_to_pay_search, store=True),
-        'payment_type': fields.function(_payment_type_get, fnct_search=_payment_type_search, method=True, type="many2one", relation="payment.type", string="Payment type"),
+        'payment_type': fields.function(_payment_type_get, fnct_search=_payment_type_search, method=True, type="many2one", relation="payment.type", string="Payment type",
+                store={
+                   'account.move.line': (lambda self, cr, uid, ids, c={}: ids,
+                                         None, 20),
+                   'payment.order': (_get_move_lines_order, ['line_ids'], 20),
+                   'payment.line': (_get_move_lines,
+                        ['type', 'move_line_id', 'payment_move_id'], 20),
+                   'account.move.reconcile': (_get_reconcile,
+                        ['line_id', 'line_partial_ids'], 20)
+                }),
+
     }
 
     def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):


Follow ups