Keep shop is defined
This commit is contained in:
parent
4f345d4700
commit
d8c88b5be0
13
sale.py
13
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'],
|
||||
|
|
Loading…
Reference in New Issue