summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-31 16:19:56 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-31 16:19:56 +0700
commitc5bcd2528adefe9312b482b0b7dcedef370056c0 (patch)
treee1b94521d9600e2273d245d37ba90e054f56ec50
parent1f491c22d519edb0df0515eba803dcd2a3436cf8 (diff)
parent5e3e425902513c9a013f208c9e374ea322e516c3 (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
-rw-r--r--indoteknik_api/controllers/controller.py4
-rw-r--r--indoteknik_custom/models/base_import_import.py30
-rw-r--r--indoteknik_custom/models/solr/product_product.py13
-rw-r--r--indoteknik_custom/models/solr/product_template.py5
-rw-r--r--indoteknik_custom/models/stock_picking.py4
5 files changed, 32 insertions, 24 deletions
diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py
index fb07708e..0592afe1 100644
--- a/indoteknik_api/controllers/controller.py
+++ b/indoteknik_api/controllers/controller.py
@@ -191,9 +191,9 @@ class Controller(http.Controller):
image = model[field] if field in model else ''
if model_name in ['product.template', 'product.product']:
- version = '2' if field not in ['image_256', 'image_512', 'image_1024', 'image_1920'] else '1'
+ version = '1' if field in ['image_256', 'image_512', 'image_1024', 'image_1920'] else '2'
ratio = kw.get('ratio', '')
- image = model['image_512'] or ''
+ image = model['image_256'] or ''
image = self.add_watermark_to_image(image, ratio, version)
response_headers = [
diff --git a/indoteknik_custom/models/base_import_import.py b/indoteknik_custom/models/base_import_import.py
index bc3b0e37..6a100cb8 100644
--- a/indoteknik_custom/models/base_import_import.py
+++ b/indoteknik_custom/models/base_import_import.py
@@ -2,27 +2,35 @@ from datetime import datetime
from odoo import models
from odoo.exceptions import UserError
+from pytz import timezone
class Import(models.TransientModel):
_inherit = 'base_import.import'
+
+ def _get_config(self, key, default = ''):
+ return self.env['ir.config_parameter'].sudo().get_param('base_import.import.' + key, default)
def _get_config_enable_import(self):
- return self.env['ir.config_parameter'].sudo().get_param('base_import.import.enable_import', '')
+ return self._get_config('enable_import')
def _get_config_allowed_model(self):
- return self.env['ir.config_parameter'].sudo().get_param('base_import.import.allowed_model', '')
+ return self._get_config('allowed_model')
+
+ def _get_config_always_allowed_model(self):
+ return self._get_config('always_allowed_model')
def _check_time_range(self, config_string):
- current_time = datetime.now().time()
+ current_time = datetime.now(tz=timezone('Asia/Jakarta')).time()
ranges = config_string.split(' / ')
for time_range in ranges:
start_str, end_str = time_range.split(' - ')
start_time = datetime.strptime(start_str, '%H:%M:%S').time()
end_time = datetime.strptime(end_str, '%H:%M:%S').time()
-
- if start_time <= current_time and current_time <= end_time:
+
+ # If current time in range of start and end time
+ if current_time >= start_time and current_time <= end_time:
return True
return False
@@ -30,16 +38,12 @@ class Import(models.TransientModel):
def _check_enable_import(self):
enable_import = self._get_config_enable_import()
allowed_model = self._get_config_allowed_model()
+ always_allowed_model = self._get_config_always_allowed_model()
- is_allowed = False
- if (allowed_model != '-' and self.res_model in allowed_model) or allowed_model == 'ALL':
- is_allowed = True
-
- if enable_import.lower() == 'false':
- return False
- elif enable_import.lower() == 'true' and is_allowed:
+ if self.res_model in always_allowed_model or always_allowed_model == 'ALL':
return True
- elif '-' in enable_import and is_allowed:
+
+ if self.res_model in allowed_model or allowed_model == 'ALL':
return self._check_time_range(enable_import)
return False
diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py
index fe2a08dc..6a0073bd 100644
--- a/indoteknik_custom/models/solr/product_product.py
+++ b/indoteknik_custom/models/solr/product_product.py
@@ -1,6 +1,7 @@
-from odoo import models, fields, api
from datetime import datetime
+from odoo import api, fields, models
+
class ProductProduct(models.Model):
_inherit = 'product.product'
@@ -37,15 +38,14 @@ class ProductProduct(models.Model):
def _sync_variants_to_solr(self):
solr_model = self.env['apache.solr']
+ ir_attachment = self.env['ir.attachment']
for variant in self:
-
category_id = 0
category_name = ''
for category in variant.product_tmpl_id.public_categ_ids:
category_id = category.id
category_name = category.name
- break
document = solr_model.get_doc('variants', variant.id)
document.update({
@@ -56,14 +56,15 @@ class ProductProduct(models.Model):
'product_rating_f': variant.product_tmpl_id.virtual_rating,
'product_id_i': variant.id,
'template_id_i': variant.product_tmpl_id.id,
- 'image_s': self.env['ir.attachment'].api_image('product.template', 'image_512', variant.product_tmpl_id.id),
+ "image_s": ir_attachment.api_image('product.product', 'image_256', variant.id),
+ 'parent_image_s': ir_attachment.api_image('product.template', 'image_256', variant.product_tmpl_id.id),
'stock_total_f': variant.qty_stock_vendor,
'weight_f': variant.product_tmpl_id.weight,
'manufacture_id_i': variant.product_tmpl_id.x_manufacture.id or 0,
'manufacture_name_s': variant.product_tmpl_id.x_manufacture.x_name or '',
'manufacture_name': variant.product_tmpl_id.x_manufacture.x_name or '',
- 'image_promotion_1_s': self.env['ir.attachment'].api_image('x_manufactures', 'image_promotion_1', variant.product_tmpl_id.x_manufacture.id),
- 'image_promotion_2_s': self.env['ir.attachment'].api_image('x_manufactures', 'image_promotion_2', variant.product_tmpl_id.x_manufacture.id),
+ 'image_promotion_1_s': ir_attachment.api_image('x_manufactures', 'image_promotion_1', variant.product_tmpl_id.x_manufacture.id),
+ 'image_promotion_2_s': ir_attachment.api_image('x_manufactures', 'image_promotion_2', variant.product_tmpl_id.x_manufacture.id),
'category_id_i': category_id,
'category_name_s': category_name,
'category_name': category_name,
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index bba98edc..062f1455 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -1,6 +1,7 @@
-from odoo import models, fields, api
from datetime import datetime
+from odoo import api, fields, models
+
class ProductTemplate(models.Model):
_inherit = "product.template"
@@ -70,7 +71,7 @@ class ProductTemplate(models.Model):
"default_code_s": template.default_code or '',
"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),
+ "image_s": self.env['ir.attachment'].api_image('product.template', 'image_256', template.id),
"variant_total_i": template.product_variant_count,
"stock_total_f": template.qty_stock_vendor,
"weight_f": template.weight,
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 1c58d954..33946f86 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -69,7 +69,9 @@ class StockPicking(models.Model):
note_logistic = fields.Selection([
('hold', 'Hold by Sales'),
('not_paid', 'Customer belum bayar'),
- ('partial', 'Kirim Parsial')
+ ('partial', 'Kirim Parsial'),
+ ('not_complete', 'Belum Lengkap'),
+ ('indent', 'Indent')
], string='Note Logistic', help='jika field ini diisi maka tidak akan dihitung ke lead time')
waybill_id = fields.One2many(comodel_name='airway.bill', inverse_name='do_id', string='Airway Bill')
purchase_representative_id = fields.Many2one('res.users', related='move_lines.purchase_line_id.order_id.user_id', string="Purchase Representative", readonly=True)