Add changes for new store
This commit is contained in:
parent
c3dcbf11d5
commit
92d1955231
27
sale.py
27
sale.py
|
@ -36,7 +36,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
Party = Pool().get('party.party')
|
Party = Pool().get('party.party')
|
||||||
User = Pool().get('res.user')
|
User = Pool().get('res.user')
|
||||||
ctx = Transaction().context
|
ctx = Transaction().context
|
||||||
print(ctx, 'ctx')
|
print(args, 'ctx')
|
||||||
if ctx.get('shop'):
|
if ctx.get('shop'):
|
||||||
shop = Shop(ctx['shop'])
|
shop = Shop(ctx['shop'])
|
||||||
if args.get('shop'):
|
if args.get('shop'):
|
||||||
|
@ -46,7 +46,15 @@ class Sale(metaclass=PoolMeta):
|
||||||
user = User(user_id)
|
user = User(user_id)
|
||||||
shop = user.shop
|
shop = user.shop
|
||||||
|
|
||||||
for v in args['lines']:
|
lines = args['lines']
|
||||||
|
nested_values = None
|
||||||
|
for line in lines:
|
||||||
|
if line and line[0] == 'create':
|
||||||
|
nested_values = line[1]
|
||||||
|
if nested_values:
|
||||||
|
lines = nested_values
|
||||||
|
for v in lines:
|
||||||
|
print('Value line to create =====>', v)
|
||||||
if v.get('id'):
|
if v.get('id'):
|
||||||
del v['id']
|
del v['id']
|
||||||
if v.get('amount'):
|
if v.get('amount'):
|
||||||
|
@ -122,14 +130,15 @@ class Sale(metaclass=PoolMeta):
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'description': description,
|
'description': description,
|
||||||
'comment': comment,
|
'comment': comment,
|
||||||
'lines': [('create', args['lines'])],
|
'lines': [('create', lines)],
|
||||||
}
|
}
|
||||||
if args.get('consumer'):
|
if args.get('consumer'):
|
||||||
to_create['consumer'] = args['consumer']
|
to_create['consumer'] = args['consumer']
|
||||||
|
if args.get('salesman'):
|
||||||
|
to_create['salesman'] = args['salesman']
|
||||||
|
if args.get('table_assigned'):
|
||||||
|
to_create['table_assigned'] = args['table_assigned']
|
||||||
sale, = cls.create([to_create])
|
sale, = cls.create([to_create])
|
||||||
# for line in sale.lines:
|
|
||||||
# if line.discount and line.discount > 0:
|
|
||||||
# line.on_change_discount()
|
|
||||||
|
|
||||||
cls.write([sale], {'state': 'quotation'})
|
cls.write([sale], {'state': 'quotation'})
|
||||||
cls.set_number([sale])
|
cls.set_number([sale])
|
||||||
|
@ -365,7 +374,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
|
|
||||||
user = User(ctx.get('user'))
|
user = User(ctx.get('user'))
|
||||||
shop = Shop(args['shop']['id'])
|
shop = Shop(args['shop']['id'])
|
||||||
attribs_del = ['id', 'amount', 'unit_price_w_tax', 'total_amount', 'discount']
|
attribs_del = ['id', 'amount', 'unit_price_w_tax', 'total_amount', 'discount']
|
||||||
for v in args['lines']:
|
for v in args['lines']:
|
||||||
keys = v.keys()
|
keys = v.keys()
|
||||||
for k in attribs_del:
|
for k in attribs_del:
|
||||||
|
@ -377,7 +386,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
if v.get('unit_price'):
|
if v.get('unit_price'):
|
||||||
v['unit_price'] = Decimal(str(v['unit_price']))
|
v['unit_price'] = Decimal(str(v['unit_price']))
|
||||||
# else:
|
# else:
|
||||||
# v['unit_price'] = product.list_price
|
# v['unit_price'] = product.list_price
|
||||||
if v.get('unit_price') == 0:
|
if v.get('unit_price') == 0:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -412,7 +421,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
'type': 'line',
|
'type': 'line',
|
||||||
'description': product.name,
|
'description': product.name,
|
||||||
'unit': product.default_uom.id,
|
'unit': product.default_uom.id,
|
||||||
'unit_price': Decimal(delivery)})
|
'unit_price': Decimal(delivery)})
|
||||||
delivery = 0
|
delivery = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=6.0.14
|
version=6.0.15
|
||||||
depends:
|
depends:
|
||||||
party
|
party
|
||||||
product
|
product
|
||||||
|
|
Loading…
Reference in New Issue