From 97364ec4c4bc7aa053389ac2e53151375ef827a1 Mon Sep 17 00:00:00 2001 From: Ludovic CHEVALIER Date: Mon, 27 Jun 2016 14:55:26 +0200 Subject: [PATCH] [PYTHON] ~use user company for search fiscal period when there is no orders in pos session --- point_of_sale.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/point_of_sale.py b/point_of_sale.py index 71b2eb6..dcfb14e 100644 --- a/point_of_sale.py +++ b/point_of_sale.py @@ -64,7 +64,10 @@ class pos_session(orm.Model): for session in self.browse(cr, uid, ids, context=context): account_move_ids = [] order_ids = [order.id for order in session.order_ids if order.state == 'done'] - company_id = order_obj.browse(cr, uid, order_ids, context=context)[0].company_id.id + if order_ids: + company_id = order_obj.browse(cr, uid, order_ids, context=context)[0].company_id.id + else: + company_id = self.pool.get('res.users').browse(cr, uid, [uid], context=context)[0].company_id.id for order in order_obj.browse(cr, uid, order_ids, context=context): if order.account_move.id not in account_move_ids: account_move_ids.append(order.account_move.id) -- 2.20.1