|
@@ -41,6 +41,7 @@ class PosSales(http.Controller):
|
|
|
from res_bank_cheque_type import get_cheque_types
|
|
|
from res_store import get_stores
|
|
|
from sale_order import get_sale_orders
|
|
|
+ from stock_picking import get_pickings
|
|
|
|
|
|
# Logic
|
|
|
check_base_currency()
|
|
@@ -81,6 +82,7 @@ class PosSales(http.Controller):
|
|
|
data = {
|
|
|
'saleOrders': get_sale_orders(),
|
|
|
'currencies': get_currencies_from_journals(),
|
|
|
+ 'customers': get_customers(image_type=config.get('imageType')),
|
|
|
'journals': get_journals(),
|
|
|
'paymentTerms': get_payment_terms(),
|
|
|
'banks': get_banks(),
|
|
@@ -91,7 +93,9 @@ class PosSales(http.Controller):
|
|
|
|
|
|
# Take data for delivery
|
|
|
if mode == 'product_delivery':
|
|
|
- data = {}
|
|
|
+ data = {
|
|
|
+ 'stockPickings': get_pickings()
|
|
|
+ }
|
|
|
|
|
|
return make_gzip_response(data)
|
|
|
|
|
@@ -164,6 +168,7 @@ class PosSales(http.Controller):
|
|
|
|
|
|
# Imports
|
|
|
from server_datetime import get_date, get_datetime
|
|
|
+ from account_journal import get_currency
|
|
|
|
|
|
'''
|
|
|
╔═╗╦╔╗╔╦╔═╗╦ ╦ ╔╗ ╦ ╦╔╦╗╔═╗╔═╗╔╦╗ ╔═╗╔═╗╔═╗ ╔═╗╦═╗╔═╗╔═╗╔═╗╔╦╗╦ ╦╦═╗╔═╗
|
|
@@ -177,6 +182,10 @@ class PosSales(http.Controller):
|
|
|
|
|
|
# Get currency
|
|
|
currency_id = get_currency(journal_id)
|
|
|
+
|
|
|
+ if not currency_id:
|
|
|
+ currency_id = request.env.user.company_id.currency_id.id
|
|
|
+
|
|
|
self.make_info_log('[OK] Getting journal')
|
|
|
|
|
|
# Create sale order
|
|
@@ -268,8 +277,57 @@ class PosSales(http.Controller):
|
|
|
╠╣ ║║║║║╚═╗╠═╣ ╠═╝╠═╣╚╦╝║║║║╣ ║║║ ║
|
|
|
╚ ╩╝╚╝╩╚═╝╩ ╩ ╩ ╩ ╩ ╩ ╩ ╩╚═╝╝╚╝ ╩
|
|
|
'''
|
|
|
- def finish_payment():
|
|
|
- pass
|
|
|
+ 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,
|
|
|
+ create_invoice_move_lines,
|
|
|
+ number_invoice,
|
|
|
+ close_invoice
|
|
|
+ )
|
|
|
+ from account_move import create_account_move
|
|
|
+ from account_voucher import create_account_voucher
|
|
|
+ from account_bank_statement import create_bank_statement
|
|
|
+ from res_bank_payment import create_bank_payment_statement
|
|
|
+
|
|
|
+ # Payment term
|
|
|
+ sale_order = request.env['sale.order'].browse(sale_order_id)
|
|
|
+ sale_order.write({
|
|
|
+ 'payment_term': payment_term_id
|
|
|
+ })
|
|
|
+
|
|
|
+ # Create invoice
|
|
|
+ invoice = create_invoice(sale_order_id, currency_id, date_now, False)
|
|
|
+ self.make_info_log('[OK] Creating invoice')
|
|
|
+
|
|
|
+ # Create invoice move lines
|
|
|
+ invoice_move_lines = create_invoice_move_lines(invoice.id, payment, date_now)
|
|
|
+ self.make_info_log('[OK] Creating invoice move lines')
|
|
|
+
|
|
|
+ # Create account move
|
|
|
+ account_move = create_account_move(invoice.id, invoice_move_lines)
|
|
|
+ self.make_info_log('[OK] Creating account move')
|
|
|
+
|
|
|
+ # Number invoice
|
|
|
+ number_invoice(invoice.id)
|
|
|
+ self.make_info_log('[OK] Number invoice')
|
|
|
+
|
|
|
+ # Create account voucher
|
|
|
+ account_voucher = create_account_voucher(account_move.id, journal_id, currency_id, payment)
|
|
|
+ self.make_info_log('[OK] Creating account voucher')
|
|
|
+
|
|
|
+ # Close invoice
|
|
|
+ close_invoice(invoice.id)
|
|
|
+ self.make_info_log('[OK] Closing invoice')
|
|
|
+
|
|
|
+ # Create bank statement
|
|
|
+ create_bank_statement(account_voucher.id, date_now)
|
|
|
+ self.make_info_log('[OK] Creating account bank statement')
|
|
|
+
|
|
|
+ # Create bank payment statement
|
|
|
+ if payment_method == 'Banco':
|
|
|
+ create_bank_payment_statement(bank_payment_data, invoice.id, account_voucher.id)
|
|
|
+ self.make_info_log('[OK] Creating bank payment statement')
|
|
|
|
|
|
'''
|
|
|
╔═╗╦╔╗╔╦╔═╗╦ ╦ ╔═╗╦═╗╔═╗╔╦╗╦ ╦╔═╗╔╦╗ ╔╦╗╔═╗╦ ╦╦ ╦╔═╗╦═╗╦ ╦
|
|
@@ -284,6 +342,7 @@ class PosSales(http.Controller):
|
|
|
╠═╝╠╦╝║ ║║ ║╣ ╚═╗╚═╗ ╠╣ ║║║║║╚═╗╠═╣ ║║║╣ ║ ║╚═╗║║ ║║║║
|
|
|
╩ ╩╚═╚═╝╚═╝╚═╝╚═╝╚═╝ ╚ ╩╝╚╝╩╚═╝╩ ╩ ═╩╝╚═╝╚═╝╩╚═╝╩╚═╝╝╚╝
|
|
|
'''
|
|
|
+
|
|
|
data = kw.get('data', [])
|
|
|
date_now = get_date()
|
|
|
|
|
@@ -298,7 +357,7 @@ class PosSales(http.Controller):
|
|
|
bank_payment_data = row.get('bankPaymentData', {})
|
|
|
|
|
|
if mode == 'budget':
|
|
|
- finish_budget_pos(journal_id, customer_id, cart_items, date_now, currency_id, payment_term_id)
|
|
|
+ finish_budget_pos(journal_id, customer_id, cart_items, date_now, payment_term_id)
|
|
|
|
|
|
if mode == 'sale':
|
|
|
finish_sale_pos(journal_id, customer_id, cart_items, date_now, payment_term_id, payment, payment_method, bank_payment_data)
|
|
@@ -307,7 +366,10 @@ class PosSales(http.Controller):
|
|
|
finish_process_picking(journal_id, customer_id, cart_items, date_now, payment_term_id)
|
|
|
|
|
|
if mode == 'payment':
|
|
|
- finish_payment()
|
|
|
+ sale_order_id = row.get('saleOrderId', None)
|
|
|
+ currency_id = row.get('currencyId', None)
|
|
|
+
|
|
|
+ finish_payment(sale_order_id, currency_id, date_now, payment_term_id, payment, payment_method, bank_payment_data)
|
|
|
|
|
|
if mode == 'product_delivery':
|
|
|
finish_product_delivery()
|