summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-05-09 14:47:45 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-05-09 14:47:45 +0700
commit2262f57b0b56b7aa1535600de20b1a1dd611a991 (patch)
tree0de5a4c64b6877c801de5e95e6caa6f89e806889
parentc50611bce3b2a57a7436f3f8b921207e36ff7f27 (diff)
parentd97277a0847bc57c0bc704c5ea62f75fadb461dc (diff)
Merge branch 'release' into staging
-rw-r--r--indoteknik_api/controllers/api_v1/__init__.py1
-rw-r--r--indoteknik_api/controllers/api_v1/banner.py1
-rw-r--r--indoteknik_api/controllers/api_v1/courier.py26
-rw-r--r--indoteknik_api/controllers/api_v1/flash_sale.py1
-rw-r--r--indoteknik_api/controllers/api_v1/user.py2
-rw-r--r--indoteknik_api/controllers/controller.py4
-rw-r--r--indoteknik_api/models/product_template.py9
-rw-r--r--indoteknik_api/models/res_users.py1
-rwxr-xr-xindoteknik_custom/__manifest__.py4
-rwxr-xr-xindoteknik_custom/models/__init__.py3
-rw-r--r--indoteknik_custom/models/account_move.py4
-rw-r--r--indoteknik_custom/models/apache_solr.py35
-rw-r--r--indoteknik_custom/models/brand_vendor.py13
-rwxr-xr-xindoteknik_custom/models/crm_lead.py39
-rw-r--r--indoteknik_custom/models/procurement_monitoring_detail.py73
-rw-r--r--indoteknik_custom/models/product_pricelist.py1
-rwxr-xr-xindoteknik_custom/models/product_template.py63
-rw-r--r--indoteknik_custom/models/raja_ongkir.py24
-rw-r--r--indoteknik_custom/models/uangmuka_pembelian.py12
-rw-r--r--indoteknik_custom/models/uangmuka_penjualan.py12
-rwxr-xr-xindoteknik_custom/models/x_banner_banner.py1
-rwxr-xr-xindoteknik_custom/models/x_manufactures.py9
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv5
-rw-r--r--indoteknik_custom/views/brand_vendor.xml60
-rw-r--r--indoteknik_custom/views/procurement_monitoring_detail.xml43
-rw-r--r--indoteknik_custom/views/product_pricelist.xml3
-rw-r--r--indoteknik_custom/views/product_product.xml16
-rwxr-xr-xindoteknik_custom/views/product_template.xml1
-rw-r--r--indoteknik_custom/views/raja_ongkir.xml179
-rwxr-xr-xindoteknik_custom/views/x_banner_banner.xml1
-rwxr-xr-xindoteknik_custom/views/x_manufactures.xml1
31 files changed, 590 insertions, 57 deletions
diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py
index 5d5f723b..d05cdf3a 100644
--- a/indoteknik_api/controllers/api_v1/__init__.py
+++ b/indoteknik_api/controllers/api_v1/__init__.py
@@ -23,3 +23,4 @@ from . import customer
from . import content
from . import midtrans
from . import wati
+from . import courier
diff --git a/indoteknik_api/controllers/api_v1/banner.py b/indoteknik_api/controllers/api_v1/banner.py
index 4db320ed..1bd0fea6 100644
--- a/indoteknik_api/controllers/api_v1/banner.py
+++ b/indoteknik_api/controllers/api_v1/banner.py
@@ -31,6 +31,7 @@ class Banner(controller.Controller):
data.append({
'name': banner.x_name,
'url': banner.x_url_banner,
+ 'background_color': banner.background_color,
'image': request.env['ir.attachment'].api_image('x_banner.banner', 'x_banner_image', banner.id),
})
diff --git a/indoteknik_api/controllers/api_v1/courier.py b/indoteknik_api/controllers/api_v1/courier.py
new file mode 100644
index 00000000..cd3e35c0
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/courier.py
@@ -0,0 +1,26 @@
+from .. import controller
+from odoo import http
+from odoo.http import request
+
+
+class Courier(controller.Controller):
+ prefix = '/api/v1/'
+
+ @http.route(prefix + 'courier', auth='public', methods=['GET', 'OPTIONS'])
+ @controller.Controller.must_authorized()
+ def get_courier(self):
+ base_url = request.env['ir.config_parameter'].get_param('web.base.url')
+ query = [
+ ('publish', '=', True),
+ ]
+
+ couriers = request.env['rajaongkir.kurir'].search(query)
+ data = []
+ for courier in couriers:
+ data.append({
+ 'id': courier.delivery_carrier_id.id,
+ 'name': courier.name,
+ 'image': base_url + 'api/image/rajaongkir.kurir/image/'+str(courier.id)
+ })
+ return self.response(data)
+ \ No newline at end of file
diff --git a/indoteknik_api/controllers/api_v1/flash_sale.py b/indoteknik_api/controllers/api_v1/flash_sale.py
index a0aaa44e..dc7c3928 100644
--- a/indoteknik_api/controllers/api_v1/flash_sale.py
+++ b/indoteknik_api/controllers/api_v1/flash_sale.py
@@ -27,6 +27,7 @@ class FlashSale(controller.Controller):
'name': pricelist.name,
'banner': request.env['ir.attachment'].api_image('product.pricelist', 'banner', pricelist.id),
'banner_mobile': request.env['ir.attachment'].api_image('product.pricelist', 'banner_mobile', pricelist.id),
+ 'banner_top': request.env['ir.attachment'].api_image('product.pricelist', 'banner_top', pricelist.id),
'duration': round((pricelist.end_date - datetime.now()).total_seconds()),
'product_total': request.env['product.pricelist.item'].search_count(query),
})
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py
index 5edb208e..d82152b7 100644
--- a/indoteknik_api/controllers/api_v1/user.py
+++ b/indoteknik_api/controllers/api_v1/user.py
@@ -16,7 +16,7 @@ class User(controller.Controller):
])
def response_with_token(self, user):
- data = request.env['res.users'].api_single_response(user)
+ data = request.env['res.users'].sudo().api_single_response(user)
data['token'] = self.create_user_token(user)
return data
diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py
index 5b20f7d4..b850bdde 100644
--- a/indoteknik_api/controllers/controller.py
+++ b/indoteknik_api/controllers/controller.py
@@ -76,7 +76,8 @@ class Controller(http.Controller):
alias = next((r.replace('alias:', '') for r in rules if r.startswith('alias:')), key)
default = next((r.replace('default:', '') for r in rules if r.startswith('default:')), None)
- if (value := kw.get(key, '')) in ['null', 'undefined']:
+ value = kw.get(key, '')
+ if value in ['null', 'undefined']:
value = ''
if 'required' in rules and not value:
result['reason'].append(f"{key} is required")
@@ -157,6 +158,7 @@ class Controller(http.Controller):
partner_child_ids = [x['id'] for x in partner.child_ids] + [partner.id]
if partner.parent_id:
partner_child_ids += [x['id'] for x in partner.parent_id.child_ids]
+ partner_child_ids += [partner.parent_id.id]
return partner_child_ids
@http.route('/api/token', auth='public', methods=['GET', 'OPTIONS'])
diff --git a/indoteknik_api/models/product_template.py b/indoteknik_api/models/product_template.py
index b9df0f5f..c3df97a5 100644
--- a/indoteknik_api/models/product_template.py
+++ b/indoteknik_api/models/product_template.py
@@ -68,10 +68,17 @@ class ProductTemplate(models.Model):
}
if with_detail != '':
+ variants = [self.env['product.product'].v2_api_single_response(variant, pricelist=pricelist) for variant in product_template.product_variant_ids]
+ lowest_price = variants[0]['price']
+ for variant in variants:
+ if variant["price"]["price_discount"] < lowest_price["price_discount"]:
+ lowest_price = variant['price']
+
data_with_detail = {
+ 'lowest_price': lowest_price,
'image': self.env['ir.attachment'].api_image('product.template', 'image_512', product_template.id),
'display_name': product_template.display_name,
- 'variants': [self.env['product.product'].v2_api_single_response(variant, pricelist=pricelist) for variant in product_template.product_variant_ids],
+ 'variants': variants,
'description': product_template.website_description or '',
}
data.update(data_with_detail)
diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py
index efe98815..80de083d 100644
--- a/indoteknik_api/models/res_users.py
+++ b/indoteknik_api/models/res_users.py
@@ -53,6 +53,7 @@ class ResUsers(models.Model):
'industry_id': user.industry_id.id or None,
'tax_name': user.nama_wajib_pajak or '',
'npwp': user.npwp or '',
+ 'rajaongkir_city_id': user.kota_id.rajaongkir_id or 0,
}
if user.kota_id:
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index e2c6eedd..d9e98975 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -70,6 +70,10 @@
'views/wati.xml',
'views/midtrans.xml',
'views/automatic_purchase.xml',
+ 'views/raja_ongkir.xml',
+ 'views/procurement_monitoring_detail.xml',
+ 'views/product_product.xml',
+ 'views/brand_vendor.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 679004d1..5dc9ce9e 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -58,3 +58,6 @@ from . import uangmuka_penjualan
from . import uangmuka_pembelian
from . import automatic_purchase
from . import apache_solr
+from . import raja_ongkir
+from . import procurement_monitoring_detail
+from . import brand_vendor \ No newline at end of file
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index db4886f4..56f3e82c 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -36,6 +36,10 @@ class AccountMove(models.Model):
res = super(AccountMove, self).action_post()
# if not self.env.user.is_accounting:
# raise UserError('Hanya Accounting yang bisa Posting')
+ if self._name == 'account.move':
+ for entry in self:
+ for line in entry.line_ids:
+ line.date_maturity = entry.date
return res
def _compute_invoice_day_to_due(self):
diff --git a/indoteknik_custom/models/apache_solr.py b/indoteknik_custom/models/apache_solr.py
index 3709e88a..b59f95cc 100644
--- a/indoteknik_custom/models/apache_solr.py
+++ b/indoteknik_custom/models/apache_solr.py
@@ -1,20 +1,46 @@
from odoo import models, api, fields
from odoo.exceptions import UserError
-from datetime import datetime
+from datetime import datetime, timedelta
import logging
import pysolr
import time
_logger = logging.getLogger(__name__)
+_solr = pysolr.Solr('http://10.148.0.5:8983/solr/product/', always_commit=True, timeout=30)
class ApacheSolr(models.Model):
_name = 'apache.solr'
_order = 'id desc'
+ def _update_rating_product_to_solr(self, limit=1000):
+ current_time = datetime.now()
+ delta_time = current_time - timedelta(days=30)
+
+ current_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
+ delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
+ templates = self.env['product.template'].search([
+ '&','&',
+ ('type', '=', 'product'),
+ ('active', '=', True),
+ '|',
+ ('last_calculate_rating', '=', False),
+ ('last_calculate_rating', '<', delta_time),
+ ], limit=limit)
+ documents=[]
+ for template in templates:
+ rating = {"set":template.virtual_rating}
+ document = {
+ "id": template.id,
+ "product_rating_f": rating
+ }
+ documents.append(document)
+ template.last_calculate_rating = current_time
+ _logger.info("[SYNC_PRODUCT_RATING_TO_SOLR] Success Set to solr product %s" % template.id)
+ _solr.add(documents)
+
def _sync_product_to_solr(self, limit=500):
- # _solr = pysolr.Solr('http://10.148.0.5:8983/solr/product/', always_commit=True, timeout=30)
- _solr = pysolr.Solr('http://192.168.23.5:8983/solr/product/', always_commit=True, timeout=30)
+ # _solr = pysolr.Solr('http://192.168.23.5:8983/solr/product/', always_commit=True, timeout=30)
start_time = time.time()
_logger.info('run sync to solr...')
query = ["&","&",("type","=","product"),("active","=",True),"|",("solr_flag","=",0),("solr_flag","=",2)]
@@ -52,6 +78,7 @@ class ApacheSolr(models.Model):
variants_name += variant.display_name or ''+', '
variants_code += variant.default_code or ''+', '
else:
+ variants_name = template.display_name
price_excl = template.product_variant_id._get_website_price_exclude_tax()
discount = template.product_variant_id._get_website_disc(0)
price_excl_after_disc = template.product_variant_id._get_website_price_after_disc_and_tax()
@@ -72,7 +99,7 @@ class ApacheSolr(models.Model):
'display_name_s': template.display_name,
'name_s': template.name,
'default_code_s': template.default_code or '',
- 'product_rating_f': template.product_rating,
+ 'product_rating_f': template.virtual_rating,
'product_id_i': template.id,
'image_s': self.env['ir.attachment'].api_image('product.template', 'image_512', template.id),
'price_f': price_excl,
diff --git a/indoteknik_custom/models/brand_vendor.py b/indoteknik_custom/models/brand_vendor.py
new file mode 100644
index 00000000..0fd122ca
--- /dev/null
+++ b/indoteknik_custom/models/brand_vendor.py
@@ -0,0 +1,13 @@
+from odoo import models, fields
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class BrandVendor(models.Model):
+ _name = 'brand.vendor'
+ _order = 'id asc'
+
+ x_manufacture_id = fields.Many2one('x_manufactures', string='Manufacture')
+ partner_id = fields.Many2one('res.partner', string='Vendor')
+ priority = fields.Integer(string='Priority', default=0)
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py
index 1f37005d..e7af4b1c 100755
--- a/indoteknik_custom/models/crm_lead.py
+++ b/indoteknik_custom/models/crm_lead.py
@@ -1,4 +1,7 @@
from odoo import fields, models, api
+import logging
+
+_logger = logging.getLogger(__name__)
class CrmLead(models.Model):
@@ -18,6 +21,11 @@ class CrmLead(models.Model):
operator_name = fields.Char('Operator Name', help='Operator yang membalas')
order_id = fields.Many2one('sale.order', string='Sales Order', help='Link ke sales order id')
+ @api.onchange('user_id')
+ def _change_salesperson_so(self):
+ if self.order_id:
+ self.order_id.user_id = self.user_id
+
def revert_to_leads(self):
opportunities = self.env['crm.lead'].search([
('type', '=', 'opportunity'),
@@ -49,18 +57,35 @@ class CrmLead(models.Model):
# ('id', '=', 12523)
], limit=1000)
for lead in leads:
- tags = self.env['crm.tag'].search([('id', '>', 0)])
+ _logger.info('processing tagged lead %s' % lead.id)
input_tags = []
- for tag in tags:
- if tag.name.lower() in lead.body_html_lead.lower():
- input_tags.append(tag.id)
- lead.tag_ids = input_tags
+ if lead.order_id:
+ last_manufacture_id = 0
+ for line in lead.order_id.order_line:
+ tag = self.env['crm.tag'].search([('name', 'ilike', line.product_id.product_tmpl_id.x_manufacture.x_name)], limit=1)
+ if tag and tag.id != last_manufacture_id:
+ last_manufacture_id = tag.id
+ input_tags.append(tag.id)
+ input_tags.append(1509) #Website hastag
+ lead.tag_ids = input_tags
+ else:
+ tags = self.env['crm.tag'].search([('id', '>', 0)])
+ for tag in tags:
+ if tag.name.lower() in lead.body_html_lead.lower():
+ input_tags.append(tag.id)
+ if input_tags:
+ lead.tag_ids = input_tags
+ else:
+ input_tags.append(1510) #no tag
+ lead.tag_ids = input_tags
if not lead.partner_id:
continue
if not lead.user_id or lead.user_id.id == 2:
- if lead.partner_id.parent_id:
+ if lead.partner_id.parent_id.user_id:
salesperson_id = lead.partner_id.parent_id.user_id.id
- else:
+ elif lead.partner_id.user_id:
salesperson_id = lead.partner_id.user_id.id
+ else:
+ salesperson_id = 2
lead.user_id = salesperson_id
diff --git a/indoteknik_custom/models/procurement_monitoring_detail.py b/indoteknik_custom/models/procurement_monitoring_detail.py
new file mode 100644
index 00000000..6031e04a
--- /dev/null
+++ b/indoteknik_custom/models/procurement_monitoring_detail.py
@@ -0,0 +1,73 @@
+from odoo import fields, models, api, tools
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class SaleMonitoringDetail(models.Model):
+ _name = 'procurement.monitoring.detail'
+ _auto = False
+ _rec_name = 'sale_order_id'
+
+ id = fields.Integer()
+ sale_order_id = fields.Many2one("sale.order", string="Sale Order")
+ partner_id = fields.Many2one("res.partner", string="Customer")
+ user_id = fields.Many2one("res.users", string="Salesperson")
+ product_id = fields.Many2one("product.product", string="Product")
+ qty_so = fields.Integer(string="Qty SO")
+ qty_reserved = fields.Integer(string="Qty Reserved")
+ qty_available = fields.Integer(string="Qty Available")
+ qty_suggest = fields.Integer(string="Qty Suggest")
+ qty_po = fields.Integer(string='Qty PO')
+ date_order = fields.Datetime(string="Date Order")
+ status = fields.Char(string="Status")
+ po_ids = fields.Many2many('purchase.order', string='PO', compute='_compute_po')
+
+ def _compute_po(self):
+ for line in self:
+ query = [
+ ('order_id.sale_order_id', '=', line.sale_order_id.id),
+ ('order_id.approval_status', '=', 'approved'),
+ ('product_id', '=', line.product_id.id),
+ ]
+ pos = self.env['purchase.order.line'].search(query)
+ po_ids = []
+ for po in pos:
+ po_ids.append(po.order_id.id)
+ line.po_ids = po_ids
+
+ def init(self):
+ tools.drop_view_if_exists(self.env.cr, self._table)
+ self.env.cr.execute("""
+ CREATE OR REPLACE VIEW %s AS (
+ SELECT
+ *,
+ a.qty_so-a.qty_reserved as qty_suggest,
+ case when a.qty_po >= a.qty_so then 'cukup'
+ when a.qty_so-a.qty_reserved > 0 then 'harus beli'
+ else 'cukup' end as status
+ FROM
+ (
+ SELECT
+ sol.id AS id,
+ so.id AS sale_order_id,
+ so.partner_id as partner_id,
+ so.user_id,
+ p.id AS product_id,
+ sol.product_uom_qty AS qty_so,
+ get_qty_available(sol.product_id) as qty_available,
+ get_qty_reserved(so.id, sol.product_id) as qty_reserved,
+ get_qty_po(so.id, sol.product_id) AS qty_po,
+ so.date_order AS date_order
+ FROM sale_order so
+ JOIN sale_order_line sol ON sol.order_id = so.id
+ JOIN product_product p ON p.id = sol.product_id
+ JOIN product_template pt ON pt.id = p.product_tmpl_id
+ WHERE pt.type IN ('consu','product')
+ AND so.state IN ('sale','done')
+ AND so.create_date >= '2022-08-10'
+ and so.so_status not in ('terproses')
+ ) a
+ --where a.qty_po < a.qty_so
+ )
+ """ % self._table)
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py
index a309945d..2edaeb80 100644
--- a/indoteknik_custom/models/product_pricelist.py
+++ b/indoteknik_custom/models/product_pricelist.py
@@ -14,6 +14,7 @@ class ProductPricelist(models.Model):
('all', 'For All User'),
('registered_user', 'Only for Registered User')
], string='Flashsale Option')
+ banner_top = fields.Binary(string='Banner Top')
class ProductPricelistItem(models.Model):
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 74b4edb1..49235ec7 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -29,6 +29,7 @@ class ProductTemplate(models.Model):
have_promotion_program = fields.Boolean('Have Promotion Program', compute='_have_promotion_program',
help="Punya promotion program gak?")
product_rating = fields.Float('Product Rating', help="Digunakan untuk sorting product di website", default=0.0)
+ virtual_rating = fields.Float('Virtual Rating', compute='_compute_virtual_rating', help="Column Virtual untuk product rating, digunakan oleh Solr", default=0.0)
last_calculate_rating = fields.Datetime("Last Calculate Rating")
web_price_sorting = fields.Float('Web Price Sorting', help='Hanya digunakan untuk sorting di web, harga tidak berlaku', default=0.0)
virtual_qty = fields.Float(string='Virtual Qty', default=0)
@@ -53,6 +54,21 @@ class ProductTemplate(models.Model):
# vals['solr_flag'] = 2
# return super().write(vals)
+ def _compute_virtual_rating(self):
+ for product in self:
+ rate = 0
+ if product.web_price:
+ rate += 4
+ if product.have_promotion_program: #have discount from pricelist
+ rate += 5
+ if product.image_128:
+ rate += 3
+ if product.website_description:
+ rate += 1
+ if product.product_variant_id.qty_stock_vendor > 0:
+ rate += 2
+ product.virtual_rating = rate
+
def update_new_product(self):
current_time = datetime.now()
delta_time = current_time - timedelta(days=30)
@@ -111,21 +127,21 @@ class ProductTemplate(models.Model):
def _compute_web_price(self):
for template in self:
- product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1)
+ # product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1)
product_pricelist_item = self.env['product.pricelist.item'].search([
('pricelist_id', '=', 1),
- ('product_id', '=', product.id)], limit=1)
+ ('product_id', '=', template.product_variant_id.id)], limit=1)
price = product_pricelist_item.fixed_price
template.web_price = price
def _have_promotion_program(self):
for template in self:
- product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1)
+ # product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1)
product_pricelist_item = self.env['product.pricelist.item'].search([
('pricelist_id', '=', 4),
- ('product_id', '=', product.id)], limit=1)
+ ('product_id', '=', template.product_variant_id.id)], limit=1)
discount = product_pricelist_item.price_discount
if discount:
template.have_promotion_program = True
@@ -134,6 +150,7 @@ class ProductTemplate(models.Model):
@api.model
def _calculate_rating_product(self):
+ #["&","&",["type","=","product"],["active","=",True],"|",["last_calculate_rating","=",False],["last_calculate_rating","<","2023-01-01 00:00:00"]]
current_time = datetime.now()
delta_time = current_time - timedelta(days=30)
@@ -141,51 +158,29 @@ class ProductTemplate(models.Model):
delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
products = self.env['product.template'].search([
+ '&','&',
('type', '=', 'product'),
('active', '=', True),
+ '|',
('last_calculate_rating', '=', False),
+ ('last_calculate_rating', '<', delta_time),
# ('id', '=', 22798),
- ], limit=100)
+ ], limit=500)
for product in products:
# print("Calculate Rating Product ", product)
_logger.info("Calculate Rating Product %s" % product.id)
- product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1)
+ # product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1)
rate = 0
if product.web_price:
rate += 1
- product.web_price_sorting = product.web_price
- if product.have_promotion_program:
+ if product.have_promotion_program: #have discount from pricelist
rate += 1
if product.image_128:
- rate += 1
- if product.website_description:
- rate += 1
- if product_variant.qty_stock_vendor > 0:
- rate += 1
- product.product_rating = rate
- product.last_calculate_rating = current_time
-
- products = self.env['product.template'].search([
- ('type', '=', 'product'),
- ('active', '=', True),
- ('last_calculate_rating', '<', delta_time),
- ], limit=100)
-
- for product in products:
- print("Calculate Rating Product OutOfDate", product)
- product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1)
- rate = 0
- if product.web_price:
- rate += 1
- product.web_price_sorting = product.web_price
- if product.have_promotion_program:
- rate += 1
- if product.image_128:
- rate += 1
+ rate += 5
if product.website_description:
rate += 1
- if product_variant.qty_stock_vendor > 0:
+ if product.product_variant_id.qty_stock_vendor > 0:
rate += 1
product.product_rating = rate
product.last_calculate_rating = current_time
diff --git a/indoteknik_custom/models/raja_ongkir.py b/indoteknik_custom/models/raja_ongkir.py
new file mode 100644
index 00000000..fa02a6bf
--- /dev/null
+++ b/indoteknik_custom/models/raja_ongkir.py
@@ -0,0 +1,24 @@
+from odoo import fields, models, api
+import logging
+import json
+
+_logger = logging.getLogger(__name__)
+
+class Kurir(models.Model):
+ _name = 'rajaongkir.kurir'
+
+ delivery_carrier_id = fields.Many2one('delivery.carrier', String='Odoo Carrier', help='dimapping dengan bawaan delivery carrier di odoo')
+ name = fields.Char(string='Name', help='nama kurir sesuai dengan data yang ada di API RajaOngkir')
+ publish = fields.Boolean(string='Publish')
+ image = fields.Binary(string='Image')
+
+class State(models.Model):
+ _inherit = 'res.country.state'
+
+ rajaongkir_id = fields.Integer(string='RajaOngkir_ID', help='mapping dengan rajaongkir berdasarkan ID')
+
+
+class Kota(models.Model):
+ _inherit = 'vit.kota'
+
+ rajaongkir_id = fields.Integer(string='RajaOngkir_ID', help='mapping dengan rajaongkir berdasarkan ID')
diff --git a/indoteknik_custom/models/uangmuka_pembelian.py b/indoteknik_custom/models/uangmuka_pembelian.py
index 797d7a01..26a003fd 100644
--- a/indoteknik_custom/models/uangmuka_pembelian.py
+++ b/indoteknik_custom/models/uangmuka_pembelian.py
@@ -50,11 +50,15 @@ class UangmukaPembelian(models.TransientModel):
account_move = request.env['account.move'].create([param_header])
_logger.info('Success Create Uang Muka Pembelian %s' % account_move.name)
+ if order.partner_id.parent_id:
+ partner_id = order.partner_id.parent_id.id
+ else:
+ partner_id = order.partner_id.id
param_debit = {
'move_id': account_move.id,
'account_id': 401, # uang muka persediaan barang dagang
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': self.pay_amt,
'credit': 0,
@@ -63,7 +67,7 @@ class UangmukaPembelian(models.TransientModel):
param_debit_ongkir = {
'move_id': account_move.id,
'account_id': 536, # biaya ongkos kirim
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': self.ongkir_amt,
'credit': 0,
@@ -72,7 +76,7 @@ class UangmukaPembelian(models.TransientModel):
param_debit_selisih = {
'move_id': account_move.id,
'account_id': 561, # selisih pembayaran
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': self.selisih_amt,
'credit': 0,
@@ -82,7 +86,7 @@ class UangmukaPembelian(models.TransientModel):
param_credit = {
'move_id': account_move.id,
'account_id': self.account_id.id, # bank in transit
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': 0,
'credit': self.pay_amt + self.ongkir_amt + self.selisih_amt,
diff --git a/indoteknik_custom/models/uangmuka_penjualan.py b/indoteknik_custom/models/uangmuka_penjualan.py
index ef0e9196..93a33b52 100644
--- a/indoteknik_custom/models/uangmuka_penjualan.py
+++ b/indoteknik_custom/models/uangmuka_penjualan.py
@@ -53,11 +53,15 @@ class UangmukaPenjualan(models.TransientModel):
account_move = request.env['account.move'].create([param_header])
_logger.info('Success Create Uang Muka Penjualan %s' % account_move.name)
+ if order.partner_id.parent_id:
+ partner_id = order.partner_id.parent_id.id
+ else:
+ partner_id = order.partner_id.id
param_debit = {
'move_id': account_move.id,
'account_id': self.account_id.id, # intransit
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': self.pay_amt + self.ongkir_amt + self.selisih_amt,
'credit': 0,
@@ -67,7 +71,7 @@ class UangmukaPenjualan(models.TransientModel):
param_credit = {
'move_id': account_move.id,
'account_id': 449, # uang muka penjualan
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': 0,
'credit': self.pay_amt,
@@ -76,7 +80,7 @@ class UangmukaPenjualan(models.TransientModel):
param_ongkir_credit = {
'move_id': account_move.id,
'account_id': 550, # pendapatan ongkos kirim
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': 0,
'credit': self.ongkir_amt,
@@ -85,7 +89,7 @@ class UangmukaPenjualan(models.TransientModel):
param_selisih_credit = {
'move_id': account_move.id,
'account_id': 561, # selisih pembayaran
- 'partner_id': order.partner_id.id,
+ 'partner_id': partner_id,
'currency_id': 12,
'debit': 0,
'credit': self.selisih_amt,
diff --git a/indoteknik_custom/models/x_banner_banner.py b/indoteknik_custom/models/x_banner_banner.py
index bc80e2a9..c34b7634 100755
--- a/indoteknik_custom/models/x_banner_banner.py
+++ b/indoteknik_custom/models/x_banner_banner.py
@@ -8,6 +8,7 @@ class XBannerBanner(models.Model):
x_name = fields.Char(string="Name")
x_url_banner = fields.Char(string="URL Banner")
+ background_color = fields.Char(string="Background Color")
x_banner_image = fields.Binary(string="Image")
x_banner_category = fields.Many2one('x_banner.category', string="Banner Category")
x_relasi_manufacture = fields.Many2one('x_manufactures', string="Relasi Merek")
diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py
index dd6948a9..710bfe8a 100755
--- a/indoteknik_custom/models/x_manufactures.py
+++ b/indoteknik_custom/models/x_manufactures.py
@@ -46,6 +46,15 @@ class XManufactures(models.Model):
show_as_new_product = fields.Boolean(string='Show as New Product', help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru')
parent_id = fields.Many2one('x_manufactures', string='Parent', help='Parent Brand tersebut')
category_ids = fields.Many2many('product.public.category', string='Category', help='Brand tsb memiliki Category apa saja')
+ vendor_ids = fields.Many2many('res.partner', string='Vendor', compute='_compute_vendor_ids')
+
+ def _compute_vendor_ids(self):
+ for manufacture in self:
+ vendor_ids = []
+ brand_vendors = self.env['brand.vendor'].search([('x_manufacture_id', '=', manufacture.id)], order='priority')
+ for vendor in brand_vendors:
+ vendor_ids.append(vendor.partner_id.id)
+ manufacture.vendor_ids = vendor_ids
def cache_reset(self):
manufactures = self.env['x_manufactures'].search([
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index f7de6d3f..39504393 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -45,4 +45,7 @@ access_automatic_purchase,access.automatic.purchase,model_automatic_purchase,,1,
access_automatic_purchase_line,access.automatic.purchase.line,model_automatic_purchase_line,,1,1,1,1
access_automatic_purchase_match,access.automatic.purchase.match,model_automatic_purchase_match,,1,1,1,1
access_apache_solr,access.apache.solr,model_apache_solr,,1,1,1,1
-access_group_partner,access.group.partner,model_group_partner,,1,1,1,1 \ No newline at end of file
+access_group_partner,access.group.partner,model_group_partner,,1,1,1,1
+access_procurement_monitoring_detail,access.procurement.monitoring.detail,model_procurement_monitoring_detail,,1,1,1,1
+access_rajaongkir_kurir,access.rajaongkir.kurir,model_rajaongkir_kurir,,1,1,1,1
+access_brand_vendor,access.brand.vendor,model_brand_vendor,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/brand_vendor.xml b/indoteknik_custom/views/brand_vendor.xml
new file mode 100644
index 00000000..ee253748
--- /dev/null
+++ b/indoteknik_custom/views/brand_vendor.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<odoo>
+ <record id="brand_vendor_tree" model="ir.ui.view">
+ <field name="name">brand.vendor.tree</field>
+ <field name="model">brand.vendor</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="x_manufacture_id"/>
+ <field name="partner_id"/>
+ <field name="priority"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="brand_vendor_form" model="ir.ui.view">
+ <field name="name">brand.vendor.form</field>
+ <field name="model">brand.vendor</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <group>
+ <field name="x_manufacture_id"/>
+ <field name="partner_id"/>
+ <field name="priority"/>
+ </group>
+ </group>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <record id="brand_vendor_filter" model="ir.ui.view">
+ <field name="name">brand.vendor.filter</field>
+ <field name="model">brand.vendor</field>
+ <field name="priority" eval="15"/>
+ <field name="arch" type="xml">
+ <search string="Search Channel">
+ <field name="x_manufacture_id"/>
+ <field name="partner_id"/>
+ </search>
+ </field>
+ </record>
+
+ <record id="brand_vendor_action" model="ir.actions.act_window">
+ <field name="name">Brand Vendor</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">brand.vendor</field>
+ <field name="search_view_id" ref="brand_vendor_filter"/>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_brand_vendor"
+ name="Brand Vendor"
+ parent="purchase.menu_purchase_products"
+ sequence="6"
+ action="brand_vendor_action"
+ />
+</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/procurement_monitoring_detail.xml b/indoteknik_custom/views/procurement_monitoring_detail.xml
new file mode 100644
index 00000000..8f3827c1
--- /dev/null
+++ b/indoteknik_custom/views/procurement_monitoring_detail.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<odoo>
+ <record id="procurement_monitoring_detail_tree" model="ir.ui.view">
+ <field name="name">procurement.monitoring.detail.tree</field>
+ <field name="model">procurement.monitoring.detail</field>
+ <field name="arch" type="xml">
+ <tree create="false" multi_edit="1">
+ <field name="date_order"/>
+ <field name="sale_order_id"/>
+ <field name="partner_id"/>
+ <field name="user_id"/>
+ <field name="product_id"/>
+ <field name="qty_so"/>
+ <field name="qty_reserved"/>
+ <field name="qty_available"/>
+ <field name="qty_suggest"/>
+ <field name="po_ids" widget="many2many_tags"/>
+ <field name="qty_po"/>
+ <field name="status"
+ widget="badge"
+ decoration-danger="status == 'harus beli'"
+ decoration-success="status == 'cukup'"
+ />
+ </tree>
+ </field>
+ </record>
+
+ <record id="procurement_monitoring_detail_action" model="ir.actions.act_window">
+ <field name="name">Procurement Monitoring Detail</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">procurement.monitoring.detail</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_procurement_monitoring_detail_in_purchase"
+ name="Procurement Monitoring Detail"
+ parent="menu_monitoring_in_purchase"
+ sequence="150"
+ action="procurement_monitoring_detail_action"
+ />
+
+</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/product_pricelist.xml b/indoteknik_custom/views/product_pricelist.xml
index 4cf06e18..0ad9e200 100644
--- a/indoteknik_custom/views/product_pricelist.xml
+++ b/indoteknik_custom/views/product_pricelist.xml
@@ -17,6 +17,9 @@
<field name="banner_mobile" widget="image" attrs="{
'invisible': [('is_flash_sale', '=', False)]
}" />
+ <field name="banner_top" widget="image" attrs="{
+ 'invisible': [('is_flash_sale', '=', False)]
+ }" />
<field name="start_date" attrs="{
'invisible': [('is_flash_sale', '=', False)],
'required': [('is_flash_sale', '=', True)]
diff --git a/indoteknik_custom/views/product_product.xml b/indoteknik_custom/views/product_product.xml
new file mode 100644
index 00000000..d3ef3e15
--- /dev/null
+++ b/indoteknik_custom/views/product_product.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="product_product_tree_inherit" model="ir.ui.view">
+ <field name="name">Product Product</field>
+ <field name="model">product.product</field>
+ <field name="inherit_id" ref="product.product_product_tree_view"/>
+ <field name="arch" type="xml">
+ <field name="qty_available" position="after">
+ <field name="outgoing_qty"/>
+ <field name="incoming_qty"/>
+ </field>
+ </field>
+ </record>
+ </data>
+</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml
index 5fcb8b05..558805b1 100755
--- a/indoteknik_custom/views/product_template.xml
+++ b/indoteknik_custom/views/product_template.xml
@@ -53,6 +53,7 @@
<field name="usage"/>
<field name="specification"/>
<field name="material"/>
+ <field name="virtual_rating"/>
<field name="search_rank"/>
<field name="solr_flag"/>
</field>
diff --git a/indoteknik_custom/views/raja_ongkir.xml b/indoteknik_custom/views/raja_ongkir.xml
new file mode 100644
index 00000000..124a91ae
--- /dev/null
+++ b/indoteknik_custom/views/raja_ongkir.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="state_raja_ongkir" model="ir.ui.view">
+ <field name="name">State</field>
+ <field name="model">res.country.state</field>
+ <field name="inherit_id" ref="base.view_country_state_tree"/>
+ <field name="arch" type="xml">
+ <field name="country_id" position="after">
+ <field name="rajaongkir_id"/>
+ </field>
+ </field>
+ </record>
+ </data>
+ <data>
+ <record id="kota_raja_ongkir" model="ir.ui.view">
+ <field name="name">Kota</field>
+ <field name="model">vit.kota</field>
+ <field name="inherit_id" ref="indoteknik_custom.vit_kota_tree"/>
+ <field name="arch" type="xml">
+ <field name="state_id" position="after">
+ <field name="rajaongkir_id"/>
+ </field>
+ </field>
+ </record>
+ </data>
+
+ <data>
+ <record id="rajaongkir_kurir_tree" model="ir.ui.view">
+ <field name="name">Kurir RajaOngkir</field>
+ <field name="model">rajaongkir.kurir</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="delivery_carrier_id"/>
+ <field name="name"/>
+ <field name="image"/>
+ <field name="publish"/>
+ </tree>
+ </field>
+ </record>
+ </data>
+
+ <record id="rajaongkir_kurir_action" model="ir.actions.act_window">
+ <field name="name">Kurir RajaOngkir</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">rajaongkir.kurir</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_kurir_rajaongkir"
+ name="Kurir RajaOngkir"
+ parent="delivery.menu_delivery"
+ sequence="150"
+ action="rajaongkir_kurir_action"
+ />
+
+ <record id="rajaongkir_jne" model="rajaongkir.kurir">
+ <field name="name">jne</field>
+ <field name="delivery_carrier_id">51</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_pos" model="rajaongkir.kurir">
+ <field name="name">pos</field>
+ <field name="delivery_carrier_id">53</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_tiki" model="rajaongkir.kurir">
+ <field name="name">tiki</field>
+ <field name="delivery_carrier_id">54</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_rpx" model="rajaongkir.kurir">
+ <field name="name">rpx</field>
+ <field name="delivery_carrier_id">55</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_pandu" model="rajaongkir.kurir">
+ <field name="name">pandu</field>
+ <field name="delivery_carrier_id">56</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_wahana" model="rajaongkir.kurir">
+ <field name="name">wahana</field>
+ <field name="delivery_carrier_id">7</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_sicepat" model="rajaongkir.kurir">
+ <field name="name">sicepat</field>
+ <field name="delivery_carrier_id">27</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_jnt" model="rajaongkir.kurir">
+ <field name="name">jnt</field>
+ <field name="delivery_carrier_id">57</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_pahala" model="rajaongkir.kurir">
+ <field name="name">pahala</field>
+ <field name="delivery_carrier_id">58</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_sap" model="rajaongkir.kurir">
+ <field name="name">sap</field>
+ <field name="delivery_carrier_id">59</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_jet" model="rajaongkir.kurir">
+ <field name="name">jet</field>
+ <field name="delivery_carrier_id">60</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_indah" model="rajaongkir.kurir">
+ <field name="name">indah</field>
+ <field name="delivery_carrier_id">61</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_dse" model="rajaongkir.kurir">
+ <field name="name">dse</field>
+ <field name="delivery_carrier_id">62</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_slis" model="rajaongkir.kurir">
+ <field name="name">slis</field>
+ <field name="delivery_carrier_id">63</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_first" model="rajaongkir.kurir">
+ <field name="name">first</field>
+ <field name="delivery_carrier_id">64</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_ncs" model="rajaongkir.kurir">
+ <field name="name">ncs</field>
+ <field name="delivery_carrier_id">65</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_star" model="rajaongkir.kurir">
+ <field name="name">star</field>
+ <field name="delivery_carrier_id">66</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_lion" model="rajaongkir.kurir">
+ <field name="name">lion</field>
+ <field name="delivery_carrier_id">67</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_idl" model="rajaongkir.kurir">
+ <field name="name">idl</field>
+ <field name="delivery_carrier_id">68</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_rex" model="rajaongkir.kurir">
+ <field name="name">rex</field>
+ <field name="delivery_carrier_id">69</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_ide" model="rajaongkir.kurir">
+ <field name="name">ide</field>
+ <field name="delivery_carrier_id">70</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_sentral" model="rajaongkir.kurir">
+ <field name="name">sentral</field>
+ <field name="delivery_carrier_id">71</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_anteraja" model="rajaongkir.kurir">
+ <field name="name">anteraja</field>
+ <field name="delivery_carrier_id">72</field>
+ <field name="publish">True</field>
+ </record>
+ <record id="rajaongkir_jtl" model="rajaongkir.kurir">
+ <field name="name">jtl</field>
+ <field name="delivery_carrier_id">73</field>
+ <field name="publish">True</field>
+ </record>
+
+</odoo> \ No newline at end of file
diff --git a/indoteknik_custom/views/x_banner_banner.xml b/indoteknik_custom/views/x_banner_banner.xml
index a83ae5ab..4f3f1911 100755
--- a/indoteknik_custom/views/x_banner_banner.xml
+++ b/indoteknik_custom/views/x_banner_banner.xml
@@ -30,6 +30,7 @@
<field name="x_status_banner"/>
</group>
<group>
+ <field name="background_color"/>
<field name="x_banner_image" widget="image"/>
</group>
</group>
diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml
index ce00c980..a88c5d34 100755
--- a/indoteknik_custom/views/x_manufactures.xml
+++ b/indoteknik_custom/views/x_manufactures.xml
@@ -49,6 +49,7 @@
<field name="x_logo_manufacture" widget="image"/>
<field name="image_promotion_1" widget="image" width="80" />
<field name="image_promotion_2" widget="image" width="80" />
+ <field name="vendor_ids" widget="many2many_tags"/>
</group>
</group>
<notebook>