From d8c88b5be006723d8f43ec5d6cfaa3aaf7d23d15 Mon Sep 17 00:00:00 2001 From: Oscar Date: Thu, 20 May 2021 19:23:16 -0500 Subject: [PATCH] Keep shop is defined --- sale.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sale.py b/sale.py index 81c7a11..28d38c1 100644 --- a/sale.py +++ b/sale.py @@ -25,8 +25,14 @@ class Sale(metaclass=PoolMeta): Shop = Pool().get('sale.shop') Product = Pool().get('product.product') Party = Pool().get('party.party') - shop_id = ctx['shop'] - shop = Shop(shop_id) + User = Pool().get('res.user') + if ctx.get('shop'): + shop = Shop(ctx['shop']) + else: + user_id = ctx.get('user') + user = User(user_id) + shop = user.shop + today = date.today() for v in args['lines']: del v['id'] @@ -35,6 +41,7 @@ class Sale(metaclass=PoolMeta): product = Product(v['product']) v['unit'] = product.template.default_uom.id v['description'] = product.name + price_list = args.get('price_list', None) if price_list: price_list = price_list['id'] @@ -50,7 +57,7 @@ class Sale(metaclass=PoolMeta): agent_id = args['agent']['id'] to_create = { - 'shop': shop_id, + 'shop': shop.id, 'invoice_type': 'P', 'company': shop.company.id, 'party': args['party']['id'],