summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-01-03 11:31:57 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-01-03 11:31:57 +0700
commit083e4ab620edc20534992d6dd8b891796ecb35ce (patch)
tree811afc8b68f921c0f60ec8c73abae52fb0e5121d
parentfbea3ab095059a101d32c2f5e4f5b0f309705d28 (diff)
add window dynamic customer review
-rw-r--r--indoteknik_api/controllers/api_v1/__init__.py1
-rw-r--r--indoteknik_api/controllers/api_v1/customer.py28
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/customer_review.py16
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rw-r--r--indoteknik_custom/views/customer_review.xml55
7 files changed, 104 insertions, 1 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="customer_review_action" model="ir.actions.act_window">
+ <field name="name">Customer Review</field>
+ <field name="res_model">customer.review</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <record id="customer_review_tree" model="ir.ui.view">
+ <field name="name">Customer Review</field>
+ <field name="model">customer.review</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="sequence"/>
+ <field name="customer_name"/>
+ <field name="ulasan"/>
+ <field name="name"/>
+ <field name="jabatan"/>
+ <field name="status"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="customer_review_form" model="ir.ui.view">
+ <field name="name">Customer Review</field>
+ <field name="model">customer.review</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <group>
+ <field name="sequence"/>
+ <field name="image"/>
+ <field name="customer_name"/>
+ <field name="ulasan"/>
+ <field name="name"/>
+ <field name="jabatan"/>
+ <field name="status"/>
+ </group>
+ </group>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <menuitem
+ id="customer_review"
+ name="Customer Review"
+ parent="website_sale.menu_orders"
+ sequence="2"
+ action="customer_review_action"
+ />
+ </data>
+</odoo> \ No newline at end of file