From 9d5d223c348726fb9ab10c7d8d910ea41e88a4a1 Mon Sep 17 00:00:00 2001 From: oscar Date: Tue, 11 May 2021 23:30:46 -0500 Subject: [PATCH 1/2] Minor fix --- sale.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sale.py b/sale.py index 81c7a11..ba99d44 100644 --- a/sale.py +++ b/sale.py @@ -29,12 +29,15 @@ class Sale(metaclass=PoolMeta): shop = Shop(shop_id) today = date.today() for v in args['lines']: - del v['id'] - del v['amount'] + if v.get('id'): + del v['id'] + if v.get('amount'): + del v['amount'] v['type'] = 'line' product = Product(v['product']) v['unit'] = product.template.default_uom.id v['description'] = product.name + price_list = args.get('price_list', None) if price_list: price_list = price_list['id'] @@ -49,20 +52,28 @@ class Sale(metaclass=PoolMeta): if args.get('agent'): 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 = { 'shop': shop_id, 'invoice_type': 'P', 'company': shop.company.id, 'party': args['party']['id'], 'sale_date': today, - 'shipment_date': args['shipment_date'], + 'shipment_date': shipment_date, 'shipment_address': shipment_address_id, 'invoice_address': shipment_address_id, 'agent': agent_id, 'price_list': price_list, 'payment_term': shop.payment_term.id, 'state': 'draft', - 'description': args.get('comment', ''), + 'description': description, 'lines': [('create', args['lines'])], } sale, = cls.create([to_create]) From 96f68be41dca6a1d476eb62c1f4ba54d94bb484a Mon Sep 17 00:00:00 2001 From: oscar Date: Thu, 20 May 2021 15:08:27 -0500 Subject: [PATCH 2/2] Add unit price w tax to res --- sale.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sale.py b/sale.py index ba99d44..27b456f 100644 --- a/sale.py +++ b/sale.py @@ -134,10 +134,10 @@ class Sale(metaclass=PoolMeta): percent_commission = price_line.price_list.percent_commission #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 = { - # '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]), # 'taxes': [[('add'), taxes_ids]], 'unit_price': math.ceil(unit_price),