minor fix
This commit is contained in:
parent
615635ebca
commit
b85d5d9f07
39
sale.py
39
sale.py
|
@ -364,22 +364,27 @@ 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']
|
||||||
for v in args['lines']:
|
for v in args['lines']:
|
||||||
if v.get('id'):
|
keys = v.keys()
|
||||||
del v['id']
|
for k in attribs_del:
|
||||||
if v.get('amount'):
|
if k in keys:
|
||||||
del v['amount']
|
del v[k]
|
||||||
if v.get('unit_price_w_tax'):
|
# if v.get('id'):
|
||||||
del v['unit_price_w_tax']
|
# del v['id']
|
||||||
if v.get('total_amount'):
|
# if v.get('amount'):
|
||||||
del v['total_amount']
|
# del v['amount']
|
||||||
|
# if v.get('unit_price_w_tax'):
|
||||||
|
# del v['unit_price_w_tax']
|
||||||
|
# if v.get('total_amount') :
|
||||||
|
# del v['total_amount']
|
||||||
|
# if v.get('discount') and v['discount'] != '':
|
||||||
|
# v['discount'] = Decimal(v['discount'])/100
|
||||||
|
# elif v.get('discount'):
|
||||||
|
# del v['discount']
|
||||||
v['type'] = 'line'
|
v['type'] = 'line'
|
||||||
product = Product(v['product']['id'])
|
product = Product(v['product']['id'])
|
||||||
|
|
||||||
if v.get('discount') and v['discount'] != '':
|
|
||||||
v['discount'] = Decimal(v['discount'])/100
|
|
||||||
elif v.get('discount'):
|
|
||||||
del v['discount']
|
|
||||||
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']))
|
||||||
v['unit'] = product.template.default_uom.id
|
v['unit'] = product.template.default_uom.id
|
||||||
|
@ -414,6 +419,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
'kind': args['kind'],
|
'kind': args['kind'],
|
||||||
'delivery': delivery,
|
'delivery': delivery,
|
||||||
'shop': shop.id,
|
'shop': shop.id,
|
||||||
|
'warehouse': shop.warehouse.id,
|
||||||
'salesman': user.employee,
|
'salesman': user.employee,
|
||||||
'invoice_type': 'P',
|
'invoice_type': 'P',
|
||||||
'company': shop.company.id,
|
'company': shop.company.id,
|
||||||
|
@ -423,7 +429,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
'shipment_address': shipment_address_id,
|
'shipment_address': shipment_address_id,
|
||||||
'invoice_address': shipment_address_id,
|
'invoice_address': shipment_address_id,
|
||||||
'agent': agent_id,
|
'agent': agent_id,
|
||||||
'price_list': price_list,
|
'price_list': price_list if price_list else shop.price_list.id,
|
||||||
'payment_term': shop.payment_term.id,
|
'payment_term': shop.payment_term.id,
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'order_status': 'requested',
|
'order_status': 'requested',
|
||||||
|
@ -433,7 +439,9 @@ class Sale(metaclass=PoolMeta):
|
||||||
}
|
}
|
||||||
if args.get('consumer'):
|
if args.get('consumer'):
|
||||||
to_create['consumer'] = args['consumer']['id']
|
to_create['consumer'] = args['consumer']['id']
|
||||||
|
print('validate create', to_create)
|
||||||
sale, = cls.create([to_create])
|
sale, = cls.create([to_create])
|
||||||
|
cls.set_number([sale])
|
||||||
record = args.copy()
|
record = args.copy()
|
||||||
record.update({
|
record.update({
|
||||||
'id': sale.id,
|
'id': sale.id,
|
||||||
|
@ -445,6 +453,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
'record': record,
|
'record': record,
|
||||||
'msg': 'successful_order',
|
'msg': 'successful_order',
|
||||||
'type': 'success',
|
'type': 'success',
|
||||||
|
'status': 'ok',
|
||||||
'open_modal': True,
|
'open_modal': True,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
@ -456,6 +465,10 @@ class Sale(metaclass=PoolMeta):
|
||||||
positive response of local printer
|
positive response of local printer
|
||||||
"""
|
"""
|
||||||
sale = cls(args['sale_id'])
|
sale = cls(args['sale_id'])
|
||||||
|
if sale.state == 'draft':
|
||||||
|
sale.quote([sale])
|
||||||
|
sale.order_status = 'commanded'
|
||||||
|
sale.save()
|
||||||
for line in sale.lines:
|
for line in sale.lines:
|
||||||
line.order_sended = True
|
line.order_sended = True
|
||||||
line.save()
|
line.save()
|
||||||
|
|
Loading…
Reference in New Issue