[membership] [pos_order] corrections pour que ça marche mieux (ter).
authorJulien Moutinho <julm+burette@autogeree.net>
Wed, 27 Mar 2013 20:09:59 +0000 (21:09 +0100)
committerJulien Moutinho <julm+burette@autogeree.net>
Wed, 27 Mar 2013 20:09:59 +0000 (21:09 +0100)
pos_membership.py

index dfc164c..748fd9a 100644 (file)
@@ -69,11 +69,11 @@ class membership_line(osv.osv):
         for order in self.pool.get('pos.order').browse(cr, uid, ids, context=context):
             if order.lines:
                 list_membership_line += member_line_obj.search(cr, uid, [('pos_order_line', 'in', [ l.id for l in order.lines])], context=context)
-        res = \
-         { 'class': 'pos.order'
-         , 'ids': list_membership_line
-         }
-        #res= list_membership_line
+        #res = \
+        # { 'class': 'pos.order'
+        # , 'ids': list_membership_line
+        # }
+        res= list_membership_line
         print("DEV: [pos_membership] [membership_line] [_get_membership_lines_from_pos_order]: res=%s" % str(res))
         return res
     
@@ -114,7 +114,7 @@ class membership_line(osv.osv):
                 return False
         return True
     
-    def _state(self, cr, uid, data, name, args, context=None):
+    def _state(self, cr, uid, ids, name, args, context=None):
         """Compute the state lines
         @param self: The object pointer
         @param cr: the current row, from the database cursor,
@@ -125,32 +125,26 @@ class membership_line(osv.osv):
         @param return: Dictionary of state Value
         """
         res = {}
-        print("DEV: [pos_membership] [membership_line] [_state]: name=%s data=%s args=%s context=%s" % (str(name), str(data), str(args), str(context)))
-        if type(data) == type(list()) or data.get('class') == 'account.invoice':
-            inv_obj = self.pool.get('account.invoice')
-            if type(data) == type(list()):
-                ids = data
-            else:
-                ids = data.get('ids')
-            for line in self.browse(cr, uid, ids, context=context):
-                cr.execute('''
-                SELECT i.state, i.id FROM
-                account_invoice i
-                WHERE
-                i.id = (
-                    SELECT l.invoice_id FROM
-                    account_invoice_line l WHERE
-                    l.id = (
-                        SELECT  ml.account_invoice_line FROM
-                        membership_membership_line ml WHERE
-                        ml.id = %s
-                        )
+        print("DEV: [pos_membership] [membership_line] [_state]: name=%s ids=%s args=%s context=%s" % (str(name), str(ids), str(args), str(context)))
+        inv_obj = self.pool.get('account.invoice')
+        ord_obj = self.pool.get('pos.order')
+        for line in self.browse(cr, uid, ids, context=context):
+            cr.execute('''
+            SELECT i.state, i.id FROM
+            account_invoice i
+            WHERE
+            i.id = (
+                SELECT l.invoice_id FROM
+                account_invoice_line l WHERE
+                l.id = (
+                    SELECT  ml.account_invoice_line FROM
+                    membership_membership_line ml WHERE
+                    ml.id = %s
                     )
-                ''', (line.id,))
-                fetched = cr.fetchone()
-                if not fetched:
-                    res[line.id] = 'canceled'
-                    continue
+                )
+            ''', (line.id,))
+            fetched = cr.fetchone()
+            if fetched:
                 istate = fetched[0]
                 state = 'none'
                 if (istate == 'draft') | (istate == 'proforma'):
@@ -166,9 +160,7 @@ class membership_line(osv.osv):
                 elif istate == 'cancel':
                     state = 'canceled'
                 res[line.id] = state
-        elif data.get('class') == 'pos.order':
-            ord_obj = self.pool.get('pos.order')
-            for line in self.browse(cr, uid, data.get('ids'), context=context):
+            else:
                 cr.execute('''
                 SELECT i.state, i.id FROM
                 pos_order i