From 95794d76104f5e4408ef329e778ab4265dde3b0b Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 25 Mar 2023 12:22:23 +0700 Subject: add options method in product price --- indoteknik_api/controllers/api_v1/product.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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/', auth='public', methods=['GET']) + @http.route(prefix + 'product/template/price/', 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/', auth='public', methods=['GET']) + @http.route(prefix + 'product/product/price/', 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() -- cgit v1.2.3 From d9f3333103ff3190c4c6ccf2365ccbb41cdb16b4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 28 Mar 2023 14:58:47 +0700 Subject: add options blog api --- indoteknik_api/controllers/api_v1/blog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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/', auth='public', methods=['GET']) + @http.route(prefix + 'blog/', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() def get_blog_by_id(self, **kw): id = kw.get('id') -- cgit v1.2.3 From 60d0b36cf33785c0cf6bea1d10b344dcdb37695a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 28 Mar 2023 16:35:49 +0700 Subject: fix API get transaction, invoice --- indoteknik_api/controllers/api_v1/manufacture.py | 2 +- indoteknik_api/controllers/api_v1/sale_order.py | 6 +++--- indoteknik_api/models/account_move.py | 5 +++++ indoteknik_api/models/sale_order.py | 6 ++++++ 4 files changed, 15 insertions(+), 4 deletions(-) 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/', 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({ diff --git a/indoteknik_api/models/account_move.py b/indoteknik_api/models/account_move.py index 9bbe8c94..54e06f84 100644 --- a/indoteknik_api/models/account_move.py +++ b/indoteknik_api/models/account_move.py @@ -37,6 +37,11 @@ class AccountMove(models.Model): } for line in account_move.invoice_line_ids: product = self.env['product.product'].api_single_response(line.product_id) + product['price'] = { + 'price': line.price_unit, + 'discount_percentage': line.discount, + 'price_discount': line.price_unit - (line.price_unit * (line.discount/100)) + } product['quantity'] = line.quantity data_with_detail['products'].append(product) data.update(data_with_detail) diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index ca6baff0..76532d20 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -10,6 +10,7 @@ class SaleOrder(models.Model): 'id': sale_order.id, 'name': sale_order.name, 'sales': sale_order.user_id.name, + 'amount_tax': sale_order.amount_tax, 'amount_total': sale_order.amount_total, 'purchase_order_name': sale_order.partner_purchase_order_name, 'purchase_order_file': True if sale_order.partner_purchase_order_file else False, @@ -56,6 +57,11 @@ class SaleOrder(models.Model): } for line in sale_order.order_line: product = self.env['product.product'].api_single_response(line.product_id) + product['price'] = { + 'price': line.price_unit, + 'discount_percentage': line.discount, + 'price_discount': line.price_unit - (line.price_unit * (line.discount/100)) + } product['quantity'] = line.product_uom_qty data_with_detail['products'].append(product) for invoice in sale_order.invoice_ids: -- cgit v1.2.3 From 4cf422c5b0f687cb33eb7c0851ca2234e36d2b29 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 30 Mar 2023 12:21:35 +0700 Subject: variant price --- indoteknik_api/models/product_product.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index f83ede27..284900de 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -19,6 +19,11 @@ class ProductProduct(models.Model): 'code': product_product.default_code or '', 'name': product_product.display_name, 'price': self.env['product.pricelist'].compute_price(product_pricelist_default_discount_id, product_product.id), + 'price': { + 'price': product_product._get_website_price_exclude_tax(), + 'discount_percentage': product_product._get_website_disc(0), + 'price_discount': product_product._get_website_price_after_disc_and_tax() + }, 'stock': product_product.qty_stock_vendor, 'weight': product_product.weight, 'attributes': [x.name for x in product_product.product_template_attribute_value_ids], -- cgit v1.2.3 From 0a0e1774d7ff25dfd6605ce4dfdc7dfdeb45eb5e Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 31 Mar 2023 11:05:10 +0700 Subject: show content only iframe --- indoteknik_custom/__init__.py | 3 ++- indoteknik_custom/controllers/__init__.py | 1 + indoteknik_custom/controllers/website.py | 36 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/controllers/__init__.py create mode 100644 indoteknik_custom/controllers/website.py diff --git a/indoteknik_custom/__init__.py b/indoteknik_custom/__init__.py index 0650744f..19240f4e 100755 --- a/indoteknik_custom/__init__.py +++ b/indoteknik_custom/__init__.py @@ -1 +1,2 @@ -from . import models +from . import controllers +from . import models \ No newline at end of file diff --git a/indoteknik_custom/controllers/__init__.py b/indoteknik_custom/controllers/__init__.py new file mode 100644 index 00000000..02ab5287 --- /dev/null +++ b/indoteknik_custom/controllers/__init__.py @@ -0,0 +1 @@ +from . import website \ No newline at end of file diff --git a/indoteknik_custom/controllers/website.py b/indoteknik_custom/controllers/website.py new file mode 100644 index 00000000..2e3df519 --- /dev/null +++ b/indoteknik_custom/controllers/website.py @@ -0,0 +1,36 @@ +from odoo.http import request, Controller +from odoo import http, _ + +class Website(Controller): + @http.route('/content', auth='public') + def content(self, **kw): + url = kw.get('url', '') + iframe = f"" + style = ''' + + ''' + script = ''' + + ''' + content = '' + '' + iframe + style + script + '' + '' + return request.make_response(content, [('Access-Control-Allow-Origin', '*'), ('Access-Control-Allow-Headers', '*')]) \ No newline at end of file -- cgit v1.2.3 From 4cbb23cd48f70788d440a55b552b6fa3be44ddfe Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 31 Mar 2023 11:23:45 +0700 Subject: add optional tree field in account.move --- indoteknik_custom/views/account_move.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 4c99692d..9faf3149 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -34,6 +34,8 @@ + + -- cgit v1.2.3