|
@@ -52,6 +52,8 @@ class PosSales(http.Controller):
|
|
|
mode = kw.get('mode', 'unknown')
|
|
|
data = {}
|
|
|
|
|
|
+ warehouses = get_warehouses()
|
|
|
+
|
|
|
# Take all data
|
|
|
if mode == 'sale':
|
|
|
data = {
|
|
@@ -60,13 +62,13 @@ class PosSales(http.Controller):
|
|
|
'user': get_current_user(),
|
|
|
'currencies': get_currencies_from_journals(),
|
|
|
'journals': get_journals(),
|
|
|
- 'customers': get_customers(image_type=image_type),
|
|
|
- 'products': get_products(image_type=image_type),
|
|
|
+ 'customers': get_customers(image_type),
|
|
|
+ 'products': get_products(image_type, map(lambda x: x.get('locationStock').get('id'), warehouses)),
|
|
|
'paymentTerms': get_payment_terms(),
|
|
|
'banks': get_banks(),
|
|
|
'bankPaymentTypes': get_bank_payment_types(),
|
|
|
'chequeTypes': get_cheque_types(),
|
|
|
- 'warehouses': get_warehouses()
|
|
|
+ 'warehouses': warehouses
|
|
|
}
|
|
|
|
|
|
# Take data for picking
|
|
@@ -178,7 +180,14 @@ class PosSales(http.Controller):
|
|
|
╠╣ ║║║║║╚═╗╠═╣ ╠╩╗║ ║ ║║║ ╦║╣ ║ ╠═╝║ ║╚═╗ ╠═╝╠╦╝║ ║║ ║╣ ║║║ ║╠╦╝║╣
|
|
|
╚ ╩╝╚╝╩╚═╝╩ ╩ ╚═╝╚═╝═╩╝╚═╝╚═╝ ╩ ╩ ╚═╝╚═╝ ╩ ╩╚═╚═╝╚═╝╚═╝═╩╝╚═╝╩╚═╚═╝
|
|
|
'''
|
|
|
- def finish_budget_pos(journal_id, customer_id, cart_items, date_now, payment_term_id):
|
|
|
+ def finish_budget_pos(
|
|
|
+ journal_id,
|
|
|
+ customer_id,
|
|
|
+ cart_items,
|
|
|
+ date_now,
|
|
|
+ payment_term_id,
|
|
|
+ warehouse_id
|
|
|
+ ):
|
|
|
# Imports
|
|
|
from account_journal import get_currency
|
|
|
from sale_order import create_sale_from_cart
|
|
@@ -192,7 +201,7 @@ class PosSales(http.Controller):
|
|
|
self.make_info_log('[OK] Getting journal')
|
|
|
|
|
|
# Create sale order
|
|
|
- sale_order = create_sale_from_cart(customer_id, cart_items, date_now, currency_id, payment_term_id)
|
|
|
+ sale_order = create_sale_from_cart(customer_id, cart_items, date_now, currency_id, payment_term_id, warehouse_id)
|
|
|
self.make_info_log('[OK] Creating sale order')
|
|
|
|
|
|
return (sale_order.id, currency_id)
|
|
@@ -202,7 +211,17 @@ class PosSales(http.Controller):
|
|
|
╠╣ ║║║║║╚═╗╠═╣ ╚═╗╠═╣║ ║╣ ╠═╝║ ║╚═╗ ╠═╝╠╦╝║ ║║ ║╣ ║║║ ║╠╦╝║╣
|
|
|
╚ ╩╝╚╝╩╚═╝╩ ╩ ╚═╝╩ ╩╩═╝╚═╝ ╩ ╚═╝╚═╝ ╩ ╩╚═╚═╝╚═╝╚═╝═╩╝╚═╝╩╚═╚═╝
|
|
|
'''
|
|
|
- def finish_sale_pos(journal_id, customer_id, cart_items, date_now, payment_term_id, payment, payment_method, bank_payment_data):
|
|
|
+ def finish_sale_pos(
|
|
|
+ journal_id,
|
|
|
+ customer_id,
|
|
|
+ cart_items,
|
|
|
+ date_now,
|
|
|
+ payment_term_id,
|
|
|
+ payment,
|
|
|
+ payment_method,
|
|
|
+ bank_payment_data,
|
|
|
+ warehouse_id
|
|
|
+ ):
|
|
|
# Create budget
|
|
|
sale_order_id, currency_id = finish_budget_pos(journal_id, customer_id, cart_items, date_now, payment_term_id)
|
|
|
|
|
@@ -261,7 +280,13 @@ class PosSales(http.Controller):
|
|
|
╠╣ ║║║║║╚═╗╠═╣ ╠═╝╠╦╝║ ║ ║║║ ║║ ║ ╠═╝║║ ╠╩╗║║║║║ ╦
|
|
|
╚ ╩╝╚╝╩╚═╝╩ ╩ ╩ ╩╚═╚═╝═╩╝╚═╝╚═╝ ╩ ╩ ╩╚═╝╩ ╩╩╝╚╝╚═╝
|
|
|
'''
|
|
|
- def finish_process_picking(journal_id, customer_id, cart_items, date_now, payment_term_id):
|
|
|
+ def finish_process_picking(
|
|
|
+ journal_id,
|
|
|
+ customer_id,
|
|
|
+ cart_items,
|
|
|
+ date_now,
|
|
|
+ payment_term_id
|
|
|
+ ):
|
|
|
sale_order_id, _ = finish_budget_pos(journal_id, customer_id, cart_items, date_now, payment_term_id)
|
|
|
|
|
|
# Imports
|
|
@@ -280,7 +305,15 @@ class PosSales(http.Controller):
|
|
|
╠╣ ║║║║║╚═╗╠═╣ ╠═╝╠═╣╚╦╝║║║║╣ ║║║ ║
|
|
|
╚ ╩╝╚╝╩╚═╝╩ ╩ ╩ ╩ ╩ ╩ ╩ ╩╚═╝╝╚╝ ╩
|
|
|
'''
|
|
|
- def finish_payment(sale_order_id, currency_id, date_now, payment_term_id, payment, payment_method, bank_payment_data):
|
|
|
+ def finish_payment(
|
|
|
+ sale_order_id,
|
|
|
+ currency_id,
|
|
|
+ date_now,
|
|
|
+ payment_term_id,
|
|
|
+ payment,
|
|
|
+ payment_method,
|
|
|
+ bank_payment_data
|
|
|
+ ):
|
|
|
# Imports
|
|
|
from account_invoice import (
|
|
|
create_invoice,
|
|
@@ -357,15 +390,16 @@ class PosSales(http.Controller):
|
|
|
customer_id = row.get('customerId', None)
|
|
|
cart_items = row.get('items', [])
|
|
|
payment_term_id = row.get('paymentTermId', None)
|
|
|
+ warehouse_id = row.get('warehouseId', None)
|
|
|
payment = float(row.get('payment', 0.0))
|
|
|
payment_method = row.get('paymentMethod', 'Efectivo')
|
|
|
bank_payment_data = row.get('bankPaymentData', {})
|
|
|
|
|
|
if mode == 'budget':
|
|
|
- finish_budget_pos(journal_id, customer_id, cart_items, date_now, payment_term_id)
|
|
|
+ finish_budget_pos(journal_id, customer_id, cart_items, date_now, payment_term_id, warehouse_id)
|
|
|
|
|
|
if mode == 'sale':
|
|
|
- finish_sale_pos(journal_id, customer_id, cart_items, date_now, payment_term_id, payment, payment_method, bank_payment_data)
|
|
|
+ finish_sale_pos(journal_id, customer_id, cart_items, date_now, payment_term_id, payment, payment_method, bank_payment_data, warehouse_id)
|
|
|
|
|
|
if mode == 'product_picking':
|
|
|
finish_process_picking(journal_id, customer_id, cart_items, date_now, payment_term_id)
|