Merge branch 'master' of bitbucket.org:presik/trytonpsk-dash_sale
This commit is contained in:
commit
9c5aaa613c
22
sale.py
22
sale.py
|
@ -35,8 +35,10 @@ class Sale(metaclass=PoolMeta):
|
||||||
|
|
||||||
today = date.today()
|
today = date.today()
|
||||||
for v in args['lines']:
|
for v in args['lines']:
|
||||||
del v['id']
|
if v.get('id'):
|
||||||
del v['amount']
|
del v['id']
|
||||||
|
if v.get('amount'):
|
||||||
|
del v['amount']
|
||||||
v['type'] = 'line'
|
v['type'] = 'line'
|
||||||
product = Product(v['product'])
|
product = Product(v['product'])
|
||||||
v['unit'] = product.template.default_uom.id
|
v['unit'] = product.template.default_uom.id
|
||||||
|
@ -56,20 +58,28 @@ class Sale(metaclass=PoolMeta):
|
||||||
if args.get('agent'):
|
if args.get('agent'):
|
||||||
agent_id = args['agent']['id']
|
agent_id = args['agent']['id']
|
||||||
|
|
||||||
|
shipment_date = None
|
||||||
|
if args.get('shipment_date'):
|
||||||
|
shipment_date = args['shipment_date']
|
||||||
|
|
||||||
|
description = args.get('description', '')
|
||||||
|
if not description:
|
||||||
|
description = args.get('comment', '')
|
||||||
|
|
||||||
to_create = {
|
to_create = {
|
||||||
'shop': shop.id,
|
'shop': shop.id,
|
||||||
'invoice_type': 'P',
|
'invoice_type': 'P',
|
||||||
'company': shop.company.id,
|
'company': shop.company.id,
|
||||||
'party': args['party']['id'],
|
'party': args['party']['id'],
|
||||||
'sale_date': today,
|
'sale_date': today,
|
||||||
'shipment_date': args['shipment_date'],
|
'shipment_date': shipment_date,
|
||||||
'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,
|
||||||
'payment_term': shop.payment_term.id,
|
'payment_term': shop.payment_term.id,
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'description': args.get('comment', ''),
|
'description': description,
|
||||||
'lines': [('create', args['lines'])],
|
'lines': [('create', args['lines'])],
|
||||||
}
|
}
|
||||||
sale, = cls.create([to_create])
|
sale, = cls.create([to_create])
|
||||||
|
@ -130,10 +140,10 @@ class Sale(metaclass=PoolMeta):
|
||||||
percent_commission = price_line.price_list.percent_commission
|
percent_commission = price_line.price_list.percent_commission
|
||||||
|
|
||||||
#ADD TAXES
|
#ADD TAXES
|
||||||
taxes_ids = [t.id for t in product.customer_taxes_used]
|
# taxes_ids = [t.id for t in product.customer_taxes_used]
|
||||||
# res = cls.get_price_with_tax([line], ['amount_w_tax', 'unit_price_w_tax'])
|
# res = cls.get_price_with_tax([line], ['amount_w_tax', 'unit_price_w_tax'])
|
||||||
res = {
|
res = {
|
||||||
# 'unit_price_w_tax': math.ceil(res['unit_price_w_tax'][None]),
|
'unit_price_w_tax': math.ceil(product.sale_price_taxed),
|
||||||
# 'amount_w_tax': math.ceil(res['amount_w_tax'][None]),
|
# 'amount_w_tax': math.ceil(res['amount_w_tax'][None]),
|
||||||
# 'taxes': [[('add'), taxes_ids]],
|
# 'taxes': [[('add'), taxes_ids]],
|
||||||
'unit_price': math.ceil(unit_price),
|
'unit_price': math.ceil(unit_price),
|
||||||
|
|
Loading…
Reference in New Issue