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'))
|
||||
shop = Shop(args['shop']['id'])
|
||||
attribs_del = ['id', 'amount', 'unit_price_w_tax', 'total_amount', 'discount']
|
||||
for v in args['lines']:
|
||||
if v.get('id'):
|
||||
del v['id']
|
||||
if v.get('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']
|
||||
keys = v.keys()
|
||||
for k in attribs_del:
|
||||
if k in keys:
|
||||
del v[k]
|
||||
# if v.get('id'):
|
||||
# del v['id']
|
||||
# if v.get('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'
|
||||
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'):
|
||||
v['unit_price'] = Decimal(str(v['unit_price']))
|
||||
v['unit'] = product.template.default_uom.id
|
||||
|
@ -414,6 +419,7 @@ class Sale(metaclass=PoolMeta):
|
|||
'kind': args['kind'],
|
||||
'delivery': delivery,
|
||||
'shop': shop.id,
|
||||
'warehouse': shop.warehouse.id,
|
||||
'salesman': user.employee,
|
||||
'invoice_type': 'P',
|
||||
'company': shop.company.id,
|
||||
|
@ -423,7 +429,7 @@ class Sale(metaclass=PoolMeta):
|
|||
'shipment_address': shipment_address_id,
|
||||
'invoice_address': shipment_address_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,
|
||||
'state': 'draft',
|
||||
'order_status': 'requested',
|
||||
|
@ -433,7 +439,9 @@ class Sale(metaclass=PoolMeta):
|
|||
}
|
||||
if args.get('consumer'):
|
||||
to_create['consumer'] = args['consumer']['id']
|
||||
print('validate create', to_create)
|
||||
sale, = cls.create([to_create])
|
||||
cls.set_number([sale])
|
||||
record = args.copy()
|
||||
record.update({
|
||||
'id': sale.id,
|
||||
|
@ -445,6 +453,7 @@ class Sale(metaclass=PoolMeta):
|
|||
'record': record,
|
||||
'msg': 'successful_order',
|
||||
'type': 'success',
|
||||
'status': 'ok',
|
||||
'open_modal': True,
|
||||
}
|
||||
return res
|
||||
|
@ -456,6 +465,10 @@ class Sale(metaclass=PoolMeta):
|
|||
positive response of local printer
|
||||
"""
|
||||
sale = cls(args['sale_id'])
|
||||
if sale.state == 'draft':
|
||||
sale.quote([sale])
|
||||
sale.order_status = 'commanded'
|
||||
sale.save()
|
||||
for line in sale.lines:
|
||||
line.order_sended = True
|
||||
line.save()
|
||||
|
|
Loading…
Reference in New Issue