From 083e4ab620edc20534992d6dd8b891796ecb35ce Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 3 Jan 2023 11:31:57 +0700 Subject: add window dynamic customer review --- indoteknik_api/controllers/api_v1/__init__.py | 1 + indoteknik_api/controllers/api_v1/customer.py | 28 +++++++++++++ indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/customer_review.py | 16 ++++++++ indoteknik_custom/security/ir.model.access.csv | 3 +- indoteknik_custom/views/customer_review.xml | 55 ++++++++++++++++++++++++++ 7 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 indoteknik_api/controllers/api_v1/customer.py create mode 100644 indoteknik_custom/models/customer_review.py create mode 100644 indoteknik_custom/views/customer_review.xml diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py index 5b4f38a0..2a93bcae 100644 --- a/indoteknik_api/controllers/api_v1/__init__.py +++ b/indoteknik_api/controllers/api_v1/__init__.py @@ -11,3 +11,4 @@ from . import sale_order from . import user from . import wishlist from . import brand_homepage +from . import customer diff --git a/indoteknik_api/controllers/api_v1/customer.py b/indoteknik_api/controllers/api_v1/customer.py new file mode 100644 index 00000000..58c93376 --- /dev/null +++ b/indoteknik_api/controllers/api_v1/customer.py @@ -0,0 +1,28 @@ +from .. import controller +from odoo import http +from odoo.http import request +import ast + + +class CustomerReview(controller.Controller): + prefix = '/api/v1/' + + @http.route(prefix + 'customer_review', auth='public', methods=['GET', 'OPTIONS']) + def get_customer_review(self, **kw): + if not self.authenticate(): + return self.response(code=401, description='Unauthorized') + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + query = [('status', '=', 'tayang')] + reviews = request.env['customer.review'].search(query, order='sequence') + data = [] + for review in reviews: + data.append({ + 'id': review.id, + 'sequence': review.sequence, + 'image': base_url + 'api/image/customer.review/image/' + str(review.id) if review.image else '', + 'customer_name': review.customer_name, + 'ulasan': review.ulasan, + 'name': review.name, + 'jabatan': review.jabatan + }) + return self.response(data) diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index c3821327..cf034f91 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -51,6 +51,7 @@ 'views/sales_target.xml', 'views/purchase_outstanding.xml', 'views/sales_outstanding.xml', + 'views/customer_review.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 193fd132..1190e7d0 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -39,3 +39,4 @@ from . import sales_target from . import product_spec from . import purchase_outstanding from . import sales_outstanding +from . import customer_review diff --git a/indoteknik_custom/models/customer_review.py b/indoteknik_custom/models/customer_review.py new file mode 100644 index 00000000..5fb93b2e --- /dev/null +++ b/indoteknik_custom/models/customer_review.py @@ -0,0 +1,16 @@ +from odoo import fields, models, api + + +class CustomerReview(models.Model): + _name = 'customer.review' + + sequence = fields.Integer(string='Sequence') + customer_name = fields.Char(string='Customer') + image = fields.Binary(string='Image') + ulasan = fields.Char(string='Ulasan') + name = fields.Char(string='Name') + jabatan = fields.Char(string='Jabatan') + status = fields.Selection([ + ('tayang', 'Tayang'), + ('tidak_tayang', 'Tidak Tayang') + ], string='Status') diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 82c5d741..c6d6cb4e 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -20,4 +20,5 @@ access_website_brand_homepage,access.website.brand.homepage,model_website_brand_ access_website_categories_homepage,access.website.categories.homepage,model_website_categories_homepage,,1,1,1,1 access_sales_target,access.sales.target,model_sales_target,,1,1,1,1 access_purchase_outstanding,access.purchase.outstanding,model_purchase_outstanding,,1,1,1,1 -access_sales_outstanding,access.sales.outstanding,model_sales_outstanding,,1,1,1,1 \ No newline at end of file +access_sales_outstanding,access.sales.outstanding,model_sales_outstanding,,1,1,1,1 +access_customer_review,access.customer.review,model_customer_review,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/customer_review.xml b/indoteknik_custom/views/customer_review.xml new file mode 100644 index 00000000..7d7e66df --- /dev/null +++ b/indoteknik_custom/views/customer_review.xml @@ -0,0 +1,55 @@ + + + + + Customer Review + customer.review + tree,form + + + + Customer Review + customer.review + + + + + + + + + + + + + + Customer Review + customer.review + +
+ + + + + + + + + + + + + +
+
+
+ + +
+
\ No newline at end of file -- cgit v1.2.3