summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_api/controllers/api_v1/banner.py3
-rw-r--r--indoteknik_api/controllers/api_v1/content.py31
-rw-r--r--indoteknik_api/models/__init__.py1
-rw-r--r--indoteknik_api/models/coupon_program.py36
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/leads_monitoring.py70
-rwxr-xr-xindoteknik_custom/models/sale_order.py6
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rw-r--r--indoteknik_custom/views/leads_monitoring.xml88
10 files changed, 234 insertions, 6 deletions
diff --git a/indoteknik_api/controllers/api_v1/banner.py b/indoteknik_api/controllers/api_v1/banner.py
index 9a4a9ec7..1327a749 100644
--- a/indoteknik_api/controllers/api_v1/banner.py
+++ b/indoteknik_api/controllers/api_v1/banner.py
@@ -11,7 +11,6 @@ class Banner(controller.Controller):
if not self.authenticate():
return self.response(code=401, description='Unauthorized')
- base_url = request.env['ir.config_parameter'].get_param('web.base.url')
manufacture_id = kw.get('manufacture_id')
type = kw.get('type')
limit = int(kw.get('limit', 0))
@@ -32,7 +31,7 @@ class Banner(controller.Controller):
data.append({
'name': banner.x_name,
'url': banner.x_url_banner,
- 'image': base_url + 'api/image/x_banner.banner/x_banner_image/' + str(banner.id) if banner.x_banner_image else '',
+ 'image': request.env['ir.attachment'].api_image('x_banner.banner', 'x_banner_image', banner.id),
})
return self.response(data) \ No newline at end of file
diff --git a/indoteknik_api/controllers/api_v1/content.py b/indoteknik_api/controllers/api_v1/content.py
index 3e175dc4..2d788306 100644
--- a/indoteknik_api/controllers/api_v1/content.py
+++ b/indoteknik_api/controllers/api_v1/content.py
@@ -6,11 +6,36 @@ from odoo.http import request
class WebsiteContent(controller.Controller):
prefix = '/api/v1/'
- @http.route(prefix + 'banner/category', auth='public', methods=['GET', 'OPTIONS'])
- def get_banner_by_category(self, **kw):
+ @http.route(prefix + 'coupon_program', auth='public', methods=['GET', 'OPTIONS'])
+ def get_coupon_program(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')
+
+ reward_type = str(kw.get('reward_type', ''))
+ limit = int(kw.get('limit', 0))
+ offset = int(kw.get('offset', 0))
+
+ query = [
+ ('x_studio_image_promo', '!=', ''),
+ ]
+ if reward_type:
+ query += [('reward_type', '=', reward_type)]
+
+ coupons = request.env['coupon.program'].search(query, limit=limit, offset=offset)
+ data = {
+ 'coupon_total': request.env['coupon.program'].search_count(query),
+ 'coupons': [request.env['coupon.program'].api_single_response(x) for x in coupons]
+ }
+ # print (data)
+ return self.response(data)
+
+
+
+ @http.route(prefix + 'banner/brand', auth='public', methods=['GET', 'OPTIONS'])
+ def get_banner_by_brand(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')
category_id = int(kw.get('category_id'), 0)
query = [
diff --git a/indoteknik_api/models/__init__.py b/indoteknik_api/models/__init__.py
index 12a1f7fd..d484500a 100644
--- a/indoteknik_api/models/__init__.py
+++ b/indoteknik_api/models/__init__.py
@@ -6,3 +6,4 @@ from . import res_users
from . import sale_order
from . import x_manufactures
from . import website_content
+from . import coupon_program
diff --git a/indoteknik_api/models/coupon_program.py b/indoteknik_api/models/coupon_program.py
new file mode 100644
index 00000000..7ca003cd
--- /dev/null
+++ b/indoteknik_api/models/coupon_program.py
@@ -0,0 +1,36 @@
+from odoo import models
+import datetime
+from pytz import timezone
+
+
+class CouponProgram(models.Model):
+ _inherit = 'coupon.program'
+
+ def api_single_response(self, coupon):
+ # print (coupon.display_name)
+ data = {
+ 'active': coupon.active,
+ 'discount_percentage': coupon.discount_percentage,
+ 'display_name': coupon.display_name,
+ 'id': coupon.id,
+ 'reward_type': coupon.reward_type,
+ 'reward_id': coupon.reward_id.id,
+ 'reward_product_id': coupon.reward_product_id.id,
+ 'reward_product_quantity': coupon.reward_product_quantity,
+ 'rule_date_from': self.time_to_str(coupon.rule_date_from, '%d/%m/%Y %H:%M:%S'),
+ 'rule_date_to': self.time_to_str(coupon.rule_date_to, '%d/%m/%Y %H:%M:%S'),
+ 'rule_id': coupon.rule_id.id,
+ 'rule_products_domain': coupon.rule_products_domain,
+ 'icon_program_promo': self.env['ir.attachment'].api_image('coupon.program', 'x_studio_field_Ifopn', coupon.id),
+ 'icon_program_promo2': self.env['ir.attachment'].api_image('coupon.program', 'x_studio_field_2Ul77', coupon.id),
+ 'discount_line_product_id': coupon.discount_line_product_id.id,
+ 'image_promo': self.env['ir.attachment'].api_image('coupon.program', 'x_studio_image_promo', coupon.id),
+ 'image_banner_promo': self.env['ir.attachment'].api_image('coupon.program', 'x_studio_banner_promo', coupon.id),
+ }
+ return data
+
+ def time_to_str(self, object, format):
+ time = ''
+ if isinstance(object, datetime.datetime):
+ time = object.astimezone(timezone('Asia/Jakarta')).strftime(format)
+ return time
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 66184081..1643d9d1 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -58,6 +58,7 @@
'views/website_content.xml',
'views/custom_mail_marketing.xml',
'views/website_ads.xml',
+ 'views/leads_monitoring.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 5d5ad0ec..c6fb7d4f 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -45,3 +45,4 @@ from . import x_manufactures
from . import x_partner_purchase_order
from . import x_product_tags
from . import website_ads
+from . import leads_monitoring
diff --git a/indoteknik_custom/models/leads_monitoring.py b/indoteknik_custom/models/leads_monitoring.py
new file mode 100644
index 00000000..f371ed65
--- /dev/null
+++ b/indoteknik_custom/models/leads_monitoring.py
@@ -0,0 +1,70 @@
+from odoo import fields, models, api, tools
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class LeadsMonitoring(models.Model):
+ _name = 'leads.monitoring'
+ _auto = False
+ _rec_name = 'lead_id'
+
+ id = fields.Integer()
+ lead_id = fields.Many2one('crm.lead', string='Leads')
+ create_date = fields.Datetime(string='Created')
+ lead_name = fields.Char(string='Lead')
+ contact_name = fields.Char(string='Contact Name')
+ partner_name = fields.Char(string='Partner Name')
+ email = fields.Char(string='Email')
+ phone = fields.Char(string='Phone')
+ mobile = fields.Char(string='Mobile')
+ salesperson_id = fields.Many2one('res.partner', string='Salesperson')
+ salesperson = fields.Char(string='Sales Name')
+ type = fields.Char(string='Type')
+ priority = fields.Char(string='Priority')
+ date_last_stage_update = fields.Datetime(string='Last Stage Updated')
+ stage_status = fields.Char(string='Status')
+ total_quotation = fields.Float(string='Quotation')
+ total_sales = fields.Float(string='Sales')
+
+ def init(self):
+ self._drop_view()
+ self.env.cr.execute("SELECT matviewname from pg_matviews where schemaname = 'public' and matviewname = '%s'" % self._table)
+ materialized_view = self.env.cr.fetchone()
+ if materialized_view is None:
+ self._init_materialized_view()
+
+ def action_refresh(self):
+ _logger.info("Refresh %s Materialized View..." % self._table)
+ self.env.cr.execute("Refresh Materialized View %s" % self._table)
+ _logger.info('Refresh %s View Success' % self._table)
+
+ def _drop_view(self):
+ self.env.cr.execute("SELECT viewname from pg_views where schemaname = 'public' and viewname = '%s'" % self._table)
+ standard_view = self.env.cr.fetchone()
+ if standard_view is not None:
+ self.env.cr.execute("DROP VIEW %s CASCADE" % self._table)
+
+ def _init_materialized_view(self):
+ self.env.cr.execute("""
+ CREATE MATERIALIZED VIEW %s AS (
+ select cl.id, cl.id as lead_id, cl.create_date,cl.email_from as email, cl.phone, cl.mobile, cl.name as lead_name,
+ u.partner_id as salesperson_id, p.name as salesperson, cl.type, cl.priority, cl.date_last_stage_update,
+ cl.contact_name, cl.partner_name,
+ case
+ when cl.stage_id = 2 then '3-Proses Quotation'
+ when cl.stage_id = 1 then '1-Lead / Potensi Baru'
+ when cl.stage_id = 4 then '5-Proses Berhasil'
+ when cl.stage_id = 3 then '2-Proses Lain, Visit, Etc'
+ when cl.stage_id = 5 then '4-Proses Negosiasi'
+ else '6-Undefined'
+ end as stage_status,
+ (select sum(so.amount_total) from sale_order so where so.opportunity_id = cl.id and so.state in ('draft', 'sent')) as total_quotation,
+ (select sum(so.amount_total) from sale_order so where so.opportunity_id = cl.id and so.state in ('sale')) as total_sales
+ from crm_lead cl
+ left join res_users u on u.id = cl.user_id
+ left join res_partner p on p.id = u.partner_id
+ where cl.active = 'true' and cl.stage_id not in(7)
+ order by cl.create_date desc
+ )
+ """ % self._table)
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 5a4a653b..0b9d1f44 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -52,6 +52,12 @@ class SaleOrder(models.Model):
partner_purchase_order_name = fields.Char(string='Nama PO Customer', copy=False, help="Nama purchase order customer, diisi oleh customer melalui website.", tracking=3)
partner_purchase_order_description = fields.Text(string='Keterangan PO Customer', copy=False, help="Keterangan purchase order customer, diisi oleh customer melalui website.", tracking=3)
partner_purchase_order_file = fields.Binary(string='File PO Customer', copy=False, help="File purchase order customer, diisi oleh customer melalui website.")
+ payment_status = fields.Selection([
+ ('confirm', 'Menunggu Konfirmasi'),
+ ('pending', 'Pending'),
+ ('lunas', 'Lunas'),
+ ('cancel', 'Cancel'),
+ ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web')
def calculate_so_status_beginning(self):
so_state = ['sale']
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index 9349a566..d469aa1e 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -26,4 +26,5 @@ access_website_content_channel,access.website.content.channel,model_website_cont
access_website_content,access.website.content,model_website_content,,1,1,1,1
access_invoice_reklas,access.invoice.reklas,model_invoice_reklas,,1,1,1,1
access_custom_mail_marketing,access.custom.mail.marketing,model_custom_mail_marketing,,1,1,1,1
-access_website_ads,access.website.ads,model_website_ads,,1,1,1,1 \ No newline at end of file
+access_website_ads,access.website.ads,model_website_ads,,1,1,1,1
+access_leads_monitoring,access.leads.monitoring,model_leads_monitoring,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/leads_monitoring.xml b/indoteknik_custom/views/leads_monitoring.xml
new file mode 100644
index 00000000..9e9934dd
--- /dev/null
+++ b/indoteknik_custom/views/leads_monitoring.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<odoo>
+ <record id="leads_monitoring_tree" model="ir.ui.view">
+ <field name="name">leads_monitoring.tree</field>
+ <field name="model">leads.monitoring</field>
+ <field name="arch" type="xml">
+ <tree create="false" multi_edit="1">
+ <header>
+ <button name="action_refresh" string="Refresh" class="oe_highlight" type="object" />
+ </header>
+ <field name="create_date"/>
+ <field name="lead_name"/>
+ <field name="contact_name"/>
+ <field name="partner_name"/>
+ <field name="email"/>
+ <field name="phone"/>
+ <field name="mobile"/>
+ <field name="salesperson"/>
+ <field name="type"/>
+ <field name="priority"/>
+ <field name="date_last_stage_update"/>
+ <field name="total_quotation"/>
+ <field name="total_sales"/>
+ <field name="stage_status"
+ widget="badge"
+ decoration-danger="stage_status == '1-Lead / Potensi Baru'"
+ decoration-warning="stage_status == '2-Proses Lain, Visit, Etc'"
+ decoration-success="stage_status == '5-Proses Berhasil'"
+ decoration-info="stage_status == '4-Proses Negosiasi' or stage_status == '3-Proses Quotation'"
+ />
+ </tree>
+ </field>
+ </record>
+
+ <record id="leads_monitoring_form" model="ir.ui.view">
+ <field name="name">leads.monitoring.form</field>
+ <field name="model">leads.monitoring</field>
+ <field name="arch" type="xml">
+ <form create="false" edit="false">
+ <sheet>
+ <group>
+ <group>
+ <field name="lead_id"/>
+ <field name="create_date"/>
+ <field name="lead_name"/>
+ <field name="contact_name"/>
+ <field name="partner_name"/>
+ <field name="email"/>
+ <field name="phone"/>
+ <field name="mobile"/>
+ </group>
+ <group>
+ <field name="salesperson_id"/>
+ <field name="type"/>
+ <field name="priority"/>
+ <field name="date_last_stage_update"/>
+ <field name="total_quotation"/>
+ <field name="total_sales"/>
+ <field name="stage_status"
+ widget="badge"
+ decoration-danger="stage_status == '1-Lead / Potensi Baru'"
+ decoration-warning="stage_status == '2-Proses Lain, Visit, Etc'"
+ decoration-success="stage_status == '5-Proses Berhasil'"
+ decoration-info="stage_status == '4-Proses Negosiasi' or stage_status == '3-Proses Quotation'"
+ />
+ </group>
+ </group>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <record id="leads_monitoring_action" model="ir.actions.act_window">
+ <field name="name">Leads Monitoring</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">leads.monitoring</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_leads_monitoring_in_sale"
+ name="Leads Monitoring"
+ parent="menu_monitoring_in_sale"
+ sequence="3"
+ action="leads_monitoring_action"
+ />
+
+</odoo> \ No newline at end of file