summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_api/controllers')
-rw-r--r--indoteknik_api/controllers/api_v1/invoice.py25
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py27
-rw-r--r--indoteknik_api/controllers/controller.py3
3 files changed, 12 insertions, 43 deletions
diff --git a/indoteknik_api/controllers/api_v1/invoice.py b/indoteknik_api/controllers/api_v1/invoice.py
index 5a6e8316..59cacfc4 100644
--- a/indoteknik_api/controllers/api_v1/invoice.py
+++ b/indoteknik_api/controllers/api_v1/invoice.py
@@ -34,7 +34,11 @@ class Invoice(controller.Controller):
]
if params['value']['name']:
name = params['value']['name'].replace(' ', '%')
- domain.append(('name', 'ilike', '%'+ name +'%'))
+ domain += [
+ '|',
+ ('name', 'ilike', '%'+ name +'%'),
+ ('ref', 'ilike', '%'+ name +'%')
+ ]
invoices = request.env['account.move'].search(domain, offset=offset, limit=limit)
data = {
'invoice_total': request.env['account.move'].search_count(domain),
@@ -67,23 +71,6 @@ class Invoice(controller.Controller):
data = {}
account_move = request.env['account.move'].search(domain)
if account_move:
- res_users = request.env['res.users']
- data = {
- 'id': account_move.id,
- 'name': account_move.name,
- 'purchase_order_name': account_move.ref or '',
- 'payment_term': account_move.invoice_payment_term_id.name or '',
- 'sales': account_move.invoice_user_id.name,
- 'amount_total': account_move.amount_total,
- 'amount_residual': account_move.amount_residual,
- 'invoice_date': account_move.invoice_date.strftime('%d/%m/%Y') or '',
- 'invoice_date_due': account_move.invoice_date_due.strftime('%d/%m/%Y') or '',
- 'customer': res_users.api_address_response(account_move.partner_id),
- 'products': [],
- }
- for line in account_move.invoice_line_ids:
- product = request.env['product.product'].api_single_response(line.product_id)
- product['quantity'] = line.quantity
- data['products'].append(product)
+ data = request.env['account.move'].api_v1_single_response(account_move, context='with_detail')
return self.response(data)
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 90dee56c..073f6301 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -30,7 +30,11 @@ class SaleOrder(controller.Controller):
domain = [('partner_id', 'in', partner_child_ids)]
if params['value']['name']:
name = params['value']['name'].replace(' ', '%')
- domain.append(('name', 'ilike', '%'+ name +'%'))
+ domain += [
+ '|',
+ ('name', 'ilike', '%'+ name +'%'),
+ ('partner_purchase_order_name', 'ilike', '%'+ name +'%')
+ ]
sale_orders = request.env['sale.order'].search(domain, offset=offset, limit=limit)
data = {
'sale_order_total': request.env['sale.order'].search_count(domain),
@@ -61,26 +65,7 @@ class SaleOrder(controller.Controller):
data = {}
sale_order = request.env['sale.order'].search(domain)
if sale_order:
- res_users = request.env['res.users']
- data = {
- 'id': sale_order.id,
- 'name': sale_order.name,
- 'payment_term': sale_order.payment_term_id.name or '',
- 'sales': sale_order.user_id.name or '',
- 'date_order': self.time_to_str(sale_order.date_order, '%d/%m/%Y %H:%M:%S'),
- 'purchase_order_name': sale_order.partner_purchase_order_name,
- 'products': [],
- 'amount_total': sale_order.amount_total,
- 'address': {
- 'customer': res_users.api_address_response(sale_order.partner_id),
- 'invoice': res_users.api_address_response(sale_order.partner_invoice_id),
- 'shipping': res_users.api_address_response(sale_order.partner_shipping_id)
- }
- }
- for line in sale_order.order_line:
- product = request.env['product.product'].api_single_response(line.product_id)
- product['quantity'] = line.product_uom_qty
- data['products'].append(product)
+ data = request.env['sale.order'].api_v1_single_response(sale_order, context='with_detail')
return self.response(data)
diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py
index a1a81e37..0b08a58f 100644
--- a/indoteknik_api/controllers/controller.py
+++ b/indoteknik_api/controllers/controller.py
@@ -7,11 +7,8 @@ from odoo import http
from odoo.http import request
from odoo.tools.config import config
from pytz import timezone
-import logging
import jwt
-_logger = logging.getLogger(__name__)
-
class Controller(http.Controller):
jwt_secret_key = "NTNv7j0TuYARvmNMmWXo6fKvM4o6nvaUi9ryX38ZHL1bkrnD1ObOQ8JAUmHCBq7Iy7otZcyAagBLHVKvvYaIpmMuxmARQ97jUVG16Jkpkp1wXOPsrF9zwew6TpczyHkHgX5EuLg2MeBuiTqJACs1J0apruOOJCggOtkjB4c"