summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-11-22 15:10:25 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-11-22 15:10:25 +0700
commit8124a3986e715cccbe3f27ff090820ed44948386 (patch)
tree59be941f3146a97196c70952c18db56516a9a92a
parentad62150f5eb73f28c27ca3e20760f68be8dbd281 (diff)
add website brand homepage for dynamic brand in homepage
-rw-r--r--indoteknik_api/controllers/api_v1/__init__.py3
-rw-r--r--indoteknik_api/controllers/api_v1/brand_homepage.py29
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/website_brand_homepage.py15
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rw-r--r--indoteknik_custom/views/website_brand_homepage.xml52
7 files changed, 102 insertions, 2 deletions
diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py
index af28675c..0ea9ba75 100644
--- a/indoteknik_api/controllers/api_v1/__init__.py
+++ b/indoteknik_api/controllers/api_v1/__init__.py
@@ -8,4 +8,5 @@ from . import product
from . import promotion
from . import sale_order
from . import user
-from . import wishlist \ No newline at end of file
+from . import wishlist
+from . import brand_homepage
diff --git a/indoteknik_api/controllers/api_v1/brand_homepage.py b/indoteknik_api/controllers/api_v1/brand_homepage.py
new file mode 100644
index 00000000..338e6e0e
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/brand_homepage.py
@@ -0,0 +1,29 @@
+from .. import controller
+from odoo import http
+from odoo.http import request
+
+
+class BrandHomepage(controller.Controller):
+ prefix = '/api/v1/'
+
+ @http.route(prefix + 'brand_homepage', auth='public', methods=['GET', 'OPTIONS'])
+ def get_brand_homepage(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')]
+ brands_homepage = request.env['website.brand.homepage'].search(query)
+
+ data = []
+ for brand_homepage in brands_homepage:
+ data.append({
+ 'sequence': brand_homepage.sequence,
+ 'manufacture_id': brand_homepage.manufacture_id.id,
+ 'name': brand_homepage.manufacture_id.x_name,
+ 'image': base_url + 'api/image/website.brand.homepage/image/' + str(
+ brand_homepage.id) if brand_homepage.image else '',
+ })
+
+ return self.response(data)
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index e0369306..4c42bd31 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -46,6 +46,7 @@
'views/delivery_carrier.xml',
'views/account_move.xml',
'views/dunning_run.xml',
+ 'views/website_brand_homepage.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 14df8266..54783ea4 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -32,3 +32,4 @@ from . import dunning_run
from . import stock_picking_return
from . import website_user_cart
from . import website_user_wishlist
+from . import website_brand_homepage
diff --git a/indoteknik_custom/models/website_brand_homepage.py b/indoteknik_custom/models/website_brand_homepage.py
new file mode 100644
index 00000000..7d65fd62
--- /dev/null
+++ b/indoteknik_custom/models/website_brand_homepage.py
@@ -0,0 +1,15 @@
+from odoo import fields, models
+
+
+class WebsiteBrandHomepage(models.Model):
+ _name = 'website.brand.homepage'
+ _rec_name = "manufacture_id"
+
+ manufacture_id = fields.Many2one('x_manufactures', string='Brand', help="Table manufacture / brand")
+ image = fields.Binary(string="Image")
+ url = fields.Char(string="URL")
+ sequence = fields.Integer(string="Sequence")
+ 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 d0cc631d..50990e1f 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -15,4 +15,5 @@ access_delivery_order_line,access.delivery.order.line,model_delivery_order_line,
access_dunning_run,access.dunning.run,model_dunning_run,,1,1,1,1
access_dunning_run_line,access.dunning.run.line,model_dunning_run_line,,1,1,1,1
access_website_user_cart,access.website.user.cart,model_website_user_cart,,1,1,1,1
-access_website_user_wishlist,access.website.user.wishlist,model_website_user_wishlist,,1,1,1,1 \ No newline at end of file
+access_website_user_wishlist,access.website.user.wishlist,model_website_user_wishlist,,1,1,1,1
+access_website_brand_homepage,access.website.brand.homepage,model_website_brand_homepage,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/website_brand_homepage.xml b/indoteknik_custom/views/website_brand_homepage.xml
new file mode 100644
index 00000000..71581be7
--- /dev/null
+++ b/indoteknik_custom/views/website_brand_homepage.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="website_brand_homepage_action" model="ir.actions.act_window">
+ <field name="name">Website Brand Homepage</field>
+ <field name="res_model">website.brand.homepage</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <record id="website_brand_homepage_tree" model="ir.ui.view">
+ <field name="name">Website Brand Homepage</field>
+ <field name="model">website.brand.homepage</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="id"/>
+ <field name="sequence"/>
+ <field name="manufacture_id"/>
+ <field name="url"/>
+ <field name="status"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="website_brand_homepage_form" model="ir.ui.view">
+ <field name="name">Website Brand Homepage</field>
+ <field name="model">website.brand.homepage</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <group>
+ <field name="sequence"/>
+ <field name="manufacture_id"/>
+ <field name="image"/>
+ <field name="url"/>
+ <field name="status"/>
+ </group>
+ </group>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <menuitem
+ id="website_brand_homepage"
+ name="Website Brand Homepage"
+ parent="website_sale.menu_orders"
+ sequence="1"
+ action="website_brand_homepage_action"
+ />
+ </data>
+</odoo> \ No newline at end of file