summaryrefslogtreecommitdiff
path: root/fixco_api/controllers/api_v1/sale.py
diff options
context:
space:
mode:
Diffstat (limited to 'fixco_api/controllers/api_v1/sale.py')
-rw-r--r--fixco_api/controllers/api_v1/sale.py37
1 files changed, 31 insertions, 6 deletions
diff --git a/fixco_api/controllers/api_v1/sale.py b/fixco_api/controllers/api_v1/sale.py
index a4bc7d0..7649407 100644
--- a/fixco_api/controllers/api_v1/sale.py
+++ b/fixco_api/controllers/api_v1/sale.py
@@ -183,8 +183,7 @@ class Sales(controller.Controller):
@http.route(prefix + 'invoice/create', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized()
- def complete_delivery_order(self, **kw):
- print(1)
+ def create_invoice(self, **kw):
sale_id = int(kw.get('id', '0'))
ref = str(kw.get('ref', '0'))
if sale_id == 0 and ref == '0':
@@ -195,9 +194,35 @@ class Sales(controller.Controller):
query = [('client_order_ref', '=', ref)]
sales = request.env['sale.order'].search(query)
- invoiced = ''
+ invoiced = []
for sale in sales:
invoiced = sale.api_create_invoices(sale.id)
- return self.response([{
- 'invoiced': str(invoiced)
- }])
+ return self.response(invoiced)
+
+ @http.route(prefix + 'invoice/paid', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
+ @controller.Controller.must_authorized()
+ def paid_invoice(self, **kw):
+ # action_create_payments in account_payment_register.py
+ sale_id = int(kw.get('id', '0'))
+ ref = str(kw.get('ref', '0'))
+ if sale_id == 0 and ref == '0':
+ return self.response(code=500, description='Internal Server Error')
+ if sale_id > 0:
+ query = [('id', '=', sale_id)]
+ else:
+ query = [('client_order_ref', '=', ref)]
+
+ sales = request.env['sale.order'].search(query)
+ for sale in sales:
+ for invoice in sale.invoice_ids:
+ invoice._register_payment_automatically()
+ # register = invoice.env['account.payment.register'].create({
+ # 'journal_id': 24,
+ # 'payment_method_id': 1,
+ # 'partner_bank_id': 5,
+ # 'amount': invoice.amount_total,
+ # 'payment_date': '2024-05-31 08:50:00',
+ # 'communication': invoice.name
+ # })
+ # register.action_create_payments()
+ return self.response({'status': True})