← Back to team overview

savoirfairelinux-openerp team mailing list archive

lp:~camptocamp/e-commerce-addons/7.0-sale_payment_method-view_automatic_payment into lp:e-commerce-addons

 

Guewen Baconnier @ Camptocamp has proposed merging lp:~camptocamp/e-commerce-addons/7.0-sale_payment_method-view_automatic_payment into lp:e-commerce-addons.

Requested reviews:
  extra-addons-commiter (extra-addons-commiter)
Related bugs:
  Bug #1269294 in e-commerce-addons: "button 'View Automatic Payment' does not work on the sales orders"
  https://bugs.launchpad.net/e-commerce-addons/+bug/1269294

For more details, see:
https://code.launchpad.net/~camptocamp/e-commerce-addons/7.0-sale_payment_method-view_automatic_payment/+merge/201729

Fixes lp:1269294

Again, the payment_method_ids relation has been modified from account.move to account.move.line but not updated everywhere...

Here, we still want to display the moves so we get their ids from the move lines of 'payment_ids'.
-- 
https://code.launchpad.net/~camptocamp/e-commerce-addons/7.0-sale_payment_method-view_automatic_payment/+merge/201729
Your team extra-addons-commiter is requested to review the proposed merge of lp:~camptocamp/e-commerce-addons/7.0-sale_payment_method-view_automatic_payment into lp:e-commerce-addons.
=== modified file 'sale_payment_method/sale.py'
--- sale_payment_method/sale.py	2014-01-14 12:49:52 +0000
+++ sale_payment_method/sale.py	2014-01-15 08:47:13 +0000
@@ -265,9 +265,12 @@
         mod_obj = self.pool.get('ir.model.data')
         act_obj = self.pool.get('ir.actions.act_window')
 
-        payment_ids = []
+        move_ids = set()
         for so in self.browse(cr, uid, ids, context=context):
-            payment_ids += [move.id for move in so.payment_ids]
+            # payment_ids are move lines, we want to display the moves
+            move_ids |= set([move_line.move_id.id for move_line
+                             in so.payment_ids])
+        move_ids = list(move_ids)
 
         ref = mod_obj.get_object_reference(cr, uid, 'account',
                                            'action_move_journal_line')
@@ -277,13 +280,13 @@
         action = act_obj.read(cr, uid, [action_id], context=context)[0]
 
         # choose the view_mode accordingly
-        if len(payment_ids) > 1:
-            action['domain'] = str([('id', 'in', payment_ids)])
+        if len(move_ids) > 1:
+            action['domain'] = str([('id', 'in', move_ids)])
         else:
             ref = mod_obj.get_object_reference(cr, uid, 'account',
                                                'view_move_form')
             action['views'] = [(ref[1] if ref else False, 'form')]
-            action['res_id'] = payment_ids[0] if payment_ids else False
+            action['res_id'] = move_ids[0] if move_ids else False
         return action
 
     def action_cancel(self, cr, uid, ids, context=None):


Follow ups