Keep shop is defined

This commit is contained in:
Oscar 2021-05-20 19:23:16 -05:00
parent 4f345d4700
commit d8c88b5be0
1 changed files with 10 additions and 3 deletions

13
sale.py
View File

@ -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'],