summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-03-31 14:01:35 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-03-31 14:01:35 +0700
commit92ca4ca8d5e16a90c1cfa8d00248c1e12c95d9fd (patch)
tree2069fd0295c5538e8023dc7c3331e6470dd7acea /indoteknik_api/controllers
parent690903a2cc7a83e8ec2453a703241539016036b6 (diff)
parent4cbb23cd48f70788d440a55b552b6fa3be44ddfe (diff)
Merge branch 'release' of bitbucket.org:altafixco/indoteknik-addons into release
Diffstat (limited to 'indoteknik_api/controllers')
-rw-r--r--indoteknik_api/controllers/api_v1/blog.py4
-rw-r--r--indoteknik_api/controllers/api_v1/manufacture.py2
-rw-r--r--indoteknik_api/controllers/api_v1/product.py8
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py6
4 files changed, 10 insertions, 10 deletions
diff --git a/indoteknik_api/controllers/api_v1/blog.py b/indoteknik_api/controllers/api_v1/blog.py
index 5f4f728e..fcca2f32 100644
--- a/indoteknik_api/controllers/api_v1/blog.py
+++ b/indoteknik_api/controllers/api_v1/blog.py
@@ -6,7 +6,7 @@ from odoo.http import request
class Blog(controller.Controller):
prefix = '/api/v1/'
- @http.route(prefix + 'blog', auth='public', methods=['GET'])
+ @http.route(prefix + 'blog', auth='public', methods=['GET', 'OPTIONS'])
@controller.Controller.must_authorized()
def get_blog(self, **kw):
limit = int(kw.get('limit', 0))
@@ -24,7 +24,7 @@ class Blog(controller.Controller):
}
return self.response(data)
- @http.route(prefix + 'blog/<id>', auth='public', methods=['GET'])
+ @http.route(prefix + 'blog/<id>', auth='public', methods=['GET', 'OPTIONS'])
@controller.Controller.must_authorized()
def get_blog_by_id(self, **kw):
id = kw.get('id')
diff --git a/indoteknik_api/controllers/api_v1/manufacture.py b/indoteknik_api/controllers/api_v1/manufacture.py
index e49872be..345fd660 100644
--- a/indoteknik_api/controllers/api_v1/manufacture.py
+++ b/indoteknik_api/controllers/api_v1/manufacture.py
@@ -32,7 +32,7 @@ class Manufacture(controller.Controller):
'manufactures': [request.env['x_manufactures'].api_single_response(x) for x in manufactures]
}
- return self.response(data)
+ return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')])
@http.route(prefix + 'manufacture/<id>', auth='public', methods=['GET', 'OPTIONS'])
@controller.Controller.must_authorized()
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py
index 6789a8f5..736fd68e 100644
--- a/indoteknik_api/controllers/api_v1/product.py
+++ b/indoteknik_api/controllers/api_v1/product.py
@@ -12,7 +12,7 @@ _logger = logging.getLogger(__name__)
class Product(controller.Controller):
prefix = '/api/v1/'
- @http.route(prefix + 'product/template/price/<id>', auth='public', methods=['GET'])
+ @http.route(prefix + 'product/template/price/<id>', auth='public', methods=['GET', 'OPTIONS'])
def get_product_template_price_by_id(self, **kw):
if not self.authenticate():
return self.response(code=401, description='Unauthorized')
@@ -48,9 +48,9 @@ class Product(controller.Controller):
}
data.update(start_from)
- return self.response(data)
+ return self.response(data, headers=[('Cache-Control', 'max-age=180, private')])
- @http.route(prefix + 'product/product/price/<id>', auth='public', methods=['GET'])
+ @http.route(prefix + 'product/product/price/<id>', auth='public', methods=['GET', 'OPTIONS'])
def get_product_product_price_by_id(self, **kw):
if not self.authenticate():
return self.response(code=401, description='Unauthorized')
@@ -67,7 +67,7 @@ class Product(controller.Controller):
'tax': product_product._get_website_tax()
}
- return self.response(data)
+ return self.response(data, headers=[('Cache-Control', 'max-age=180, private')])
@http.route(prefix + 'new_product', auth='public', methods=['GET', 'OPTIONS'])
@controller.Controller.must_authorized()
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 34583c37..76fbfddb 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -253,14 +253,14 @@ class SaleOrder(controller.Controller):
order_line = json.loads(params['value']['order_line'])
parameters = []
for line in order_line:
- price = request.env['product.pricelist'].compute_price(product_pricelist_default_discount_id, line['product_id'])
+ product = request.env['product.product'].search([('id', '=', line['product_id'])], limit=1)
parameters.append({
'company_id': 1,
'order_id': sale_order.id,
'product_id': line['product_id'],
'product_uom_qty': line['quantity'],
- 'price_subtotal': price['price'],
- 'discount': price['discount_percentage']
+ 'price_subtotal': product._get_website_price_exclude_tax(),
+ 'discount': product._get_website_disc(0)
})
request.env['sale.order.line'].create(parameters)
return self.response({