|
@@ -12,12 +12,13 @@ from purchase_order import (get_purchase_orders, get_purchase_order, create_purc
|
|
from res_bank_cheque_type import get_cheque_types
|
|
from res_bank_cheque_type import get_cheque_types
|
|
from res_bank_payments_type import get_bank_payment_types
|
|
from res_bank_payments_type import get_bank_payment_types
|
|
from res_bank import get_banks
|
|
from res_bank import get_banks
|
|
-from res_currency import check_base_currency, get_currency_id
|
|
|
|
|
|
+from res_currency import check_base_currency, get_base_currency
|
|
from res_partner import get_suppliers
|
|
from res_partner import get_suppliers
|
|
from res_users import get_current_user
|
|
from res_users import get_current_user
|
|
from server_date import get_date
|
|
from server_date import get_date
|
|
from stock_picking_type import get_picking_types
|
|
from stock_picking_type import get_picking_types
|
|
from stock_picking import get_pickings
|
|
from stock_picking import get_pickings
|
|
|
|
+from stock_warehouse import get_warehouses
|
|
|
|
|
|
|
|
|
|
def get_data(mode=None):
|
|
def get_data(mode=None):
|
|
@@ -25,34 +26,43 @@ def get_data(mode=None):
|
|
|
|
|
|
check_base_currency()
|
|
check_base_currency()
|
|
|
|
|
|
|
|
+ warehouses = get_warehouses()
|
|
|
|
+ location_ids = map(lambda x: x.get('locationStock').get('id'), warehouses)
|
|
|
|
+ currencies = get_currencies_from_journal()
|
|
|
|
+
|
|
|
|
+ if len(currencies) == 0:
|
|
|
|
+ currencies = [get_base_currency()]
|
|
|
|
+
|
|
if mode == 'purchase' or mode == 'expense':
|
|
if mode == 'purchase' or mode == 'expense':
|
|
data = {
|
|
data = {
|
|
'date': get_date(),
|
|
'date': get_date(),
|
|
'user': get_current_user(),
|
|
'user': get_current_user(),
|
|
- 'currencies': get_currencies_from_journal(),
|
|
|
|
|
|
+ 'currencies': currencies,
|
|
'journals': get_journals(),
|
|
'journals': get_journals(),
|
|
'suppliers': get_suppliers(),
|
|
'suppliers': get_suppliers(),
|
|
- 'products': get_products(mode),
|
|
|
|
|
|
+ 'products': get_products(mode, location_ids),
|
|
'pickingTypes': get_picking_types(),
|
|
'pickingTypes': get_picking_types(),
|
|
'paymentTerms': get_payment_terms(),
|
|
'paymentTerms': get_payment_terms(),
|
|
'banks': get_banks(),
|
|
'banks': get_banks(),
|
|
'bankPaymentTypes': get_bank_payment_types(),
|
|
'bankPaymentTypes': get_bank_payment_types(),
|
|
- 'chequeTypes': get_cheque_types()
|
|
|
|
|
|
+ 'chequeTypes': get_cheque_types(),
|
|
|
|
+ 'warehouses': warehouses
|
|
}
|
|
}
|
|
|
|
|
|
if mode == 'product_picking':
|
|
if mode == 'product_picking':
|
|
data = {
|
|
data = {
|
|
'date': get_date(),
|
|
'date': get_date(),
|
|
'user': get_current_user(),
|
|
'user': get_current_user(),
|
|
- 'currencies': get_currencies_from_journal(),
|
|
|
|
|
|
+ 'currencies': currencies,
|
|
'suppliers': get_suppliers(),
|
|
'suppliers': get_suppliers(),
|
|
- 'products': get_products()
|
|
|
|
|
|
+ 'products': get_products('purchase', location_ids),
|
|
|
|
+ 'warehouses': warehouses
|
|
}
|
|
}
|
|
|
|
|
|
if mode == 'payment':
|
|
if mode == 'payment':
|
|
data = {
|
|
data = {
|
|
'purchaseOrders': get_purchase_orders(),
|
|
'purchaseOrders': get_purchase_orders(),
|
|
- 'currencies': get_currencies_from_journal(),
|
|
|
|
|
|
+ 'currencies': currencies,
|
|
'suppliers': get_suppliers(),
|
|
'suppliers': get_suppliers(),
|
|
'journals': get_journals(),
|
|
'journals': get_journals(),
|
|
'paymentTerms': get_payment_terms(),
|
|
'paymentTerms': get_payment_terms(),
|
|
@@ -73,8 +83,7 @@ def process_data(data=None):
|
|
if not data:
|
|
if not data:
|
|
return {}
|
|
return {}
|
|
|
|
|
|
- def drafting_order(journal_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id):
|
|
|
|
- currency_id = get_currency_id(journal_id)
|
|
|
|
|
|
+ def drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id):
|
|
pricelist_id = get_pricelist_id(currency_id)
|
|
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)
|
|
order = create_purchase_order(supplier_id, cart_items, date_now, currency_id, pricelist_id, payment_term_id, warehouse_id)
|
|
@@ -133,27 +142,28 @@ def process_data(data=None):
|
|
|
|
|
|
date_now = get_date()
|
|
date_now = get_date()
|
|
mode = data.get('mode')
|
|
mode = data.get('mode')
|
|
|
|
+ currency_id = data.get('currencyId')
|
|
journal_id = data.get('journalId')
|
|
journal_id = data.get('journalId')
|
|
supplier_id = data.get('supplierId')
|
|
supplier_id = data.get('supplierId')
|
|
supplier_invoice_number = data.get('supplierInvoiceNumber', None)
|
|
supplier_invoice_number = data.get('supplierInvoiceNumber', None)
|
|
cart_items = data.get('items')
|
|
cart_items = data.get('items')
|
|
payment_term_id = data.get('paymentTermId')
|
|
payment_term_id = data.get('paymentTermId')
|
|
warehouse_id = data.get('warehouseId', None)
|
|
warehouse_id = data.get('warehouseId', None)
|
|
- payment = float(data.get('payment'))
|
|
|
|
|
|
+ payment = float(data.get('payment', 0.0))
|
|
|
|
|
|
if mode not in ('product_picking', 'payment', 'product_taking'):
|
|
if mode not in ('product_picking', 'payment', 'product_taking'):
|
|
order_id = None
|
|
order_id = None
|
|
|
|
|
|
if mode == 'purchase':
|
|
if mode == 'purchase':
|
|
- order_id, currency_id = drafting_order(journal_id, supplier_id, cart_items, date_now, payment_term_id)
|
|
|
|
|
|
+ order_id, currency_id = drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id)
|
|
making_order(order_id)
|
|
making_order(order_id)
|
|
complete_order(order_id)
|
|
complete_order(order_id)
|
|
else:
|
|
else:
|
|
paying_order(order_id)
|
|
paying_order(order_id)
|
|
|
|
|
|
if mode == 'product_picking':
|
|
if mode == 'product_picking':
|
|
- order_id, currency_id = drafting_order(journal_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id)
|
|
|
|
- making_order(order_id)
|
|
|
|
|
|
+ order_id, currency_id = drafting_order(currency_id, supplier_id, cart_items, date_now, payment_term_id, warehouse_id)
|
|
|
|
+ confirm_purchase_order(order_id)
|
|
|
|
|
|
if mode == 'payment':
|
|
if mode == 'payment':
|
|
order_id = data.get('orderId')
|
|
order_id = data.get('orderId')
|