minor fix
This commit is contained in:
parent
e32f88365a
commit
3150b5e2dd
42
sale.py
42
sale.py
|
@ -388,33 +388,33 @@ class Sale(metaclass=PoolMeta):
|
|||
ctx = Transaction().context
|
||||
|
||||
user = User(ctx.get('user'))
|
||||
shop = Shop(args['shop']['id'])
|
||||
attribs_del = ['id', 'amount', 'unit_price_w_tax', 'total_amount', 'discount']
|
||||
for v in args['lines']:
|
||||
shop = Shop(args['shop'])
|
||||
attribs_del = ['id', 'amount', 'unit_price_w_tax', 'total_amount']
|
||||
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:
|
||||
keys = v.keys()
|
||||
for k in attribs_del:
|
||||
if k in keys:
|
||||
del v[k]
|
||||
v['type'] = 'line'
|
||||
product = Product(v['product']['id'])
|
||||
|
||||
if v.get('unit_price'):
|
||||
product = Product(v['product'])
|
||||
v['unit_price'] = Decimal(str(v['unit_price']))
|
||||
# else:
|
||||
# v['unit_price'] = product.list_price
|
||||
if v.get('unit_price') == 0:
|
||||
pass
|
||||
else:
|
||||
v['base_price'] = product.list_price
|
||||
v['unit'] = product.template.default_uom.id
|
||||
v['description'] = product.name
|
||||
v['product'] = v['product']['id']
|
||||
v['base_price'] = Decimal(str(v['base_price']))
|
||||
if v.get('discount'):
|
||||
v['discount'] = Decimal(str(v['discount']))
|
||||
|
||||
taxes = list(product.account_category.customer_taxes_used)
|
||||
taxes_ids = [t.id for t in taxes]
|
||||
v['taxes'] = [('add', taxes_ids)]
|
||||
|
||||
price_list = args.get('price_list', None)
|
||||
party = Party(args['party']['id'])
|
||||
party = Party(args['party'])
|
||||
if args.get('shipment_address'):
|
||||
shipment_address_id = args.get('shipment_address')
|
||||
else:
|
||||
|
@ -445,8 +445,8 @@ class Sale(metaclass=PoolMeta):
|
|||
date_ = datetime.now() - timedelta(hours=5)
|
||||
today = date(date_.year, date_.month, date_.day)
|
||||
to_create = {
|
||||
'consumer': args['consumer']['id'],
|
||||
'source': args['source']['id'],
|
||||
'consumer': args['consumer'],
|
||||
'source': args['source'],
|
||||
'kind': args['kind'],
|
||||
'delivery_amount': delivery,
|
||||
'shop': shop.id,
|
||||
|
@ -468,10 +468,10 @@ class Sale(metaclass=PoolMeta):
|
|||
'order_status': 'requested',
|
||||
'description': description,
|
||||
'comment': comment,
|
||||
'lines': [('create', args['lines'])],
|
||||
'lines': [('create', lines)],
|
||||
}
|
||||
if args.get('consumer'):
|
||||
to_create['consumer'] = args['consumer']['id']
|
||||
to_create['consumer'] = args['consumer']
|
||||
order_status_time = OrderStatusTime.create([{ 'requested': datetime.now()}])
|
||||
to_create['order_status_time'] = order_status_time[0].id
|
||||
print(to_create, 'validate to create')
|
||||
|
@ -487,7 +487,7 @@ class Sale(metaclass=PoolMeta):
|
|||
})
|
||||
res = {
|
||||
'record': record,
|
||||
'msg': 'successful_order',
|
||||
'msg': f'Venta creada {sale.number}',
|
||||
'type': 'success',
|
||||
'status': 'ok',
|
||||
'open_modal': True,
|
||||
|
|
Loading…
Reference in New Issue