From c436c33bc26b76b13518fc1682dbdc8c13678515 Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Wed, 27 Mar 2013 21:09:59 +0100 Subject: [PATCH] =?utf8?q?[membership]=20[pos=5Forder]=20corrections=20pou?= =?utf8?q?r=20que=20=C3=A7a=20marche=20mieux=20(ter).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- pos_membership.py | 60 ++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/pos_membership.py b/pos_membership.py index dfc164c..748fd9a 100644 --- a/pos_membership.py +++ b/pos_membership.py @@ -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 -- 2.20.1