set options discounts
This commit is contained in:
parent
f81124e5dc
commit
398894e9a0
23
sale.py
23
sale.py
|
@ -298,6 +298,17 @@ class Sale(metaclass=PoolMeta):
|
||||||
'ctx': ctx,
|
'ctx': ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def dash_get_reverse_sale_price_taxed(cls, args):
|
||||||
|
pool = Pool()
|
||||||
|
Tax = pool.get('account.tax')
|
||||||
|
Product = pool.get('product.product')
|
||||||
|
product = Product(args['product'])
|
||||||
|
sale_price_taxed = args['sale_price_taxed']
|
||||||
|
taxes = product.customer_taxes_used
|
||||||
|
unit_price = Tax.reverse_compute(Decimal(sale_price_taxed), taxes)
|
||||||
|
return {'unit_price': unit_price}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dash_get_line(cls, args, ctx):
|
def dash_get_line(cls, args, ctx):
|
||||||
if not args.get('product'):
|
if not args.get('product'):
|
||||||
|
@ -373,6 +384,9 @@ 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:
|
||||||
|
v['unit_price'] = product.list_price
|
||||||
|
v['base_price'] = product.list_price
|
||||||
v['unit'] = product.template.default_uom.id
|
v['unit'] = product.template.default_uom.id
|
||||||
v['description'] = product.name
|
v['description'] = product.name
|
||||||
v['product'] = v['product']['id']
|
v['product'] = v['product']['id']
|
||||||
|
@ -394,15 +408,17 @@ 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)
|
delivery = args.get('delivery_amount', 0)
|
||||||
if args.get('delivery_invoice') and delivery and int(delivery) > 0:
|
if args.get('delivery_invoice') and delivery and int(delivery) > 0:
|
||||||
product = config.delivery_product
|
product = config.delivery_product
|
||||||
args['lines'].append({
|
args['lines'].append({
|
||||||
'product': product.id,
|
'product': product.id,
|
||||||
'quantity': 1,
|
'quantity': 1,
|
||||||
|
'type': 'line',
|
||||||
|
'description': product.name,
|
||||||
'unit': product.default_uom.id,
|
'unit': product.default_uom.id,
|
||||||
'unit_price': Decimal(delivery)})
|
'unit_price': Decimal(delivery)})
|
||||||
delivery = None
|
delivery = 0
|
||||||
|
|
||||||
|
|
||||||
description = args.get('description', '')
|
description = args.get('description', '')
|
||||||
|
@ -412,7 +428,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
'consumer': args['consumer']['id'],
|
'consumer': args['consumer']['id'],
|
||||||
'source': args['source']['id'],
|
'source': args['source']['id'],
|
||||||
'kind': args['kind'],
|
'kind': args['kind'],
|
||||||
'delivery': delivery,
|
'delivery_amount': delivery,
|
||||||
'shop': shop.id,
|
'shop': shop.id,
|
||||||
'position': args.get('position', ''),
|
'position': args.get('position', ''),
|
||||||
'payment_method': args['payment_method'],
|
'payment_method': args['payment_method'],
|
||||||
|
@ -438,6 +454,7 @@ class Sale(metaclass=PoolMeta):
|
||||||
to_create['consumer'] = args['consumer']['id']
|
to_create['consumer'] = args['consumer']['id']
|
||||||
order_status_time = OrderStatusTime.create([{ 'requested': datetime.now()}])
|
order_status_time = OrderStatusTime.create([{ 'requested': datetime.now()}])
|
||||||
to_create['order_status_time'] = order_status_time[0].id
|
to_create['order_status_time'] = order_status_time[0].id
|
||||||
|
print(to_create, 'validate to create')
|
||||||
sale, = cls.create([to_create])
|
sale, = cls.create([to_create])
|
||||||
OrderStatusTime.write(order_status_time, {'sale': sale.id})
|
OrderStatusTime.write(order_status_time, {'sale': sale.id})
|
||||||
cls.set_number([sale])
|
cls.set_number([sale])
|
||||||
|
|
Loading…
Reference in New Issue