|
@@ -84,7 +84,7 @@ def process_data(data=None):
|
|
|
if not data:
|
|
|
return {}
|
|
|
|
|
|
- def drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id):
|
|
|
+ def drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id=None, user_id=None):
|
|
|
pricelist_id = get_pricelist_id(currency_id)
|
|
|
|
|
|
order = create_purchase_order(supplier_id, cart_items, date_now, currency_id, pricelist_id, payment_term_id, warehouse_id)
|
|
@@ -100,7 +100,7 @@ def process_data(data=None):
|
|
|
|
|
|
return order.id
|
|
|
|
|
|
- def paying_order(order_id, supplier_invoice_number=None, date_now=None, payment_term_id=None, mode=None):
|
|
|
+ def paying_order(order_id, supplier_invoice_number=None, date_now=None, payment_term_id=None, user_id=None, mode=None):
|
|
|
order = get_purchase_order(order_id)
|
|
|
|
|
|
lines = [{
|
|
@@ -110,7 +110,7 @@ def process_data(data=None):
|
|
|
'price': l.price_unit
|
|
|
} for l in order.order_line]
|
|
|
|
|
|
- invoice = create_invoice(order.partner_id.id, lines, order.currency_id.id, payment_term_id, supplier_invoice_number)
|
|
|
+ invoice = create_invoice(order.partner_id.id, lines, order.currency_id.id, payment_term_id, supplier_invoice_number, user_id)
|
|
|
|
|
|
invoice_ids = invoice.mapped(lambda x: x.id)
|
|
|
|
|
@@ -149,15 +149,17 @@ def process_data(data=None):
|
|
|
cart_items = data.get('items')
|
|
|
payment_term_id = data.get('paymentTermId')
|
|
|
warehouse_id = data.get('warehouseId', None)
|
|
|
+ user_id = data.get('userId', None)
|
|
|
payment = float(data.get('payment', 0.0))
|
|
|
|
|
|
if mode not in ('product_picking', 'payment', 'product_taking'):
|
|
|
- order_id, currency_id = drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id)
|
|
|
+ order_id, currency_id = drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id, user_id)
|
|
|
confirm_purchase_order(order_id)
|
|
|
- paying_order(order_id, supplier_invoice_number, date_now, payment_term_id, mode)
|
|
|
+ paying_order(order_id, supplier_invoice_number, date_now, payment_term_id, user_id, mode)
|
|
|
+ done_purchase_order(order_id)
|
|
|
|
|
|
if mode == 'product_picking':
|
|
|
- order_id, currency_id = drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id)
|
|
|
+ order_id, currency_id = drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id, user_id)
|
|
|
confirm_purchase_order(order_id)
|
|
|
|
|
|
if mode == 'payment':
|
|
@@ -166,7 +168,7 @@ def process_data(data=None):
|
|
|
if not order_id:
|
|
|
return
|
|
|
|
|
|
- paying_order(order_id, supplier_invoice_number, date_now, payment_term_id, mode)
|
|
|
+ paying_order(order_id, supplier_invoice_number, date_now, payment_term_id, user_id, mode)
|
|
|
done_purchase_order(order_id)
|
|
|
|
|
|
if mode == 'product_taking':
|