set time order commanded
This commit is contained in:
parent
38141a32c0
commit
96da3c7992
40
sale.py
40
sale.py
|
@ -354,34 +354,20 @@ class Sale(metaclass=PoolMeta):
|
||||||
Shop = Pool().get('sale.shop')
|
Shop = Pool().get('sale.shop')
|
||||||
Product = Pool().get('product.product')
|
Product = Pool().get('product.product')
|
||||||
Party = Pool().get('party.party')
|
Party = Pool().get('party.party')
|
||||||
|
OrderStatusTime = Pool().get('sale.order_status.time')
|
||||||
|
Configuration = Pool().get('sale.configuration')
|
||||||
|
config = Configuration(1)
|
||||||
User = Pool().get('res.user')
|
User = Pool().get('res.user')
|
||||||
ctx = Transaction().context
|
ctx = Transaction().context
|
||||||
# if ctx.get('shop'):
|
|
||||||
# shop = Shop(ctx['shop'])
|
|
||||||
# else:
|
|
||||||
# user_id = ctx.get('user')
|
|
||||||
# shop = user.shop
|
|
||||||
|
|
||||||
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:
|
||||||
if k in keys:
|
if k in keys:
|
||||||
del v[k]
|
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'
|
v['type'] = 'line'
|
||||||
product = Product(v['product']['id'])
|
product = Product(v['product']['id'])
|
||||||
|
|
||||||
|
@ -408,10 +394,19 @@ class Sale(metaclass=PoolMeta):
|
||||||
shipment_date = None
|
shipment_date = None
|
||||||
if args.get('shipment_date'):
|
if args.get('shipment_date'):
|
||||||
shipment_date = args['shipment_date']
|
shipment_date = args['shipment_date']
|
||||||
|
delivery = args.get('delivery', None)
|
||||||
|
if args.get('delivery_invoice') and delivery and int(delivery) > 0:
|
||||||
|
product = config.delivery_product
|
||||||
|
args['lines'].append({
|
||||||
|
'product': product.id,
|
||||||
|
'quantity': 1,
|
||||||
|
'unit': product.default_uom.id,
|
||||||
|
'unit_price': Decimal(delivery)})
|
||||||
|
delivery = None
|
||||||
|
|
||||||
|
|
||||||
description = args.get('description', '')
|
description = args.get('description', '')
|
||||||
comment = args.get('comment', '')
|
comment = args.get('comment', '')
|
||||||
delivery = args.get('delivery', '')
|
|
||||||
today = date.today()
|
today = date.today()
|
||||||
to_create = {
|
to_create = {
|
||||||
'consumer': args['consumer']['id'],
|
'consumer': args['consumer']['id'],
|
||||||
|
@ -439,8 +434,10 @@ 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)
|
order_status_time = OrderStatusTime.create([{ 'requested': datetime.now()}])
|
||||||
|
to_create['order_status_time'] = order_status_time[0].id
|
||||||
sale, = cls.create([to_create])
|
sale, = cls.create([to_create])
|
||||||
|
OrderStatusTime.write(order_status_time, {'sale': sale.id})
|
||||||
cls.set_number([sale])
|
cls.set_number([sale])
|
||||||
record = args.copy()
|
record = args.copy()
|
||||||
record.update({
|
record.update({
|
||||||
|
@ -468,6 +465,9 @@ class Sale(metaclass=PoolMeta):
|
||||||
if sale.state == 'draft':
|
if sale.state == 'draft':
|
||||||
sale.quote([sale])
|
sale.quote([sale])
|
||||||
sale.order_status = 'commanded'
|
sale.order_status = 'commanded'
|
||||||
|
if sale.order_status_time:
|
||||||
|
sale.order_status_time.commanded = datetime.now()
|
||||||
|
sale.order_status_time.save()
|
||||||
sale.save()
|
sale.save()
|
||||||
for line in sale.lines:
|
for line in sale.lines:
|
||||||
line.order_sended = True
|
line.order_sended = True
|
||||||
|
|
Loading…
Reference in New Issue