From 4a35b0d5432ed38395fa8f8cb6ebcfb5e0887f28 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 29 Jan 2024 14:26:20 +0700 Subject: add status note logistc --- indoteknik_custom/models/stock_picking.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 6754ebab..8ff782ba 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) -- cgit v1.2.3 From 9c3ba66d67a91a3281f8fcb2c4956f69489600ab Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 29 Jan 2024 16:04:47 +0700 Subject: Update import setting feature --- indoteknik_api/controllers/controller.py | 2 +- indoteknik_custom/models/base_import_import.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py index fb07708e..bb060cf5 100644 --- a/indoteknik_api/controllers/controller.py +++ b/indoteknik_api/controllers/controller.py @@ -191,7 +191,7 @@ 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 = self.add_watermark_to_image(image, ratio, version) diff --git a/indoteknik_custom/models/base_import_import.py b/indoteknik_custom/models/base_import_import.py index bc3b0e37..043f860c 100644 --- a/indoteknik_custom/models/base_import_import.py +++ b/indoteknik_custom/models/base_import_import.py @@ -2,6 +2,7 @@ from datetime import datetime from odoo import models from odoo.exceptions import UserError +from pytz import timezone class Import(models.TransientModel): @@ -12,17 +13,21 @@ class Import(models.TransientModel): def _get_config_allowed_model(self): return self.env['ir.config_parameter'].sudo().get_param('base_import.import.allowed_model', '') + + def _get_config_always_allowed_model(self): + return self.env['ir.config_parameter'].sudo().get_param('base_import.import.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 +35,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 -- cgit v1.2.3 From b2de86fc46f09c14e415181496bee38733d50306 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 30 Jan 2024 14:11:38 +0700 Subject: update image api source size --- indoteknik_api/controllers/controller.py | 2 +- indoteknik_custom/models/base_import_import.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py index bb060cf5..0592afe1 100644 --- a/indoteknik_api/controllers/controller.py +++ b/indoteknik_api/controllers/controller.py @@ -193,7 +193,7 @@ class Controller(http.Controller): if model_name in ['product.template', 'product.product']: 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 043f860c..6a100cb8 100644 --- a/indoteknik_custom/models/base_import_import.py +++ b/indoteknik_custom/models/base_import_import.py @@ -7,15 +7,18 @@ 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.env['ir.config_parameter'].sudo().get_param('base_import.import.always_allowed_model', '') + return self._get_config('always_allowed_model') def _check_time_range(self, config_string): current_time = datetime.now(tz=timezone('Asia/Jakarta')).time() -- cgit v1.2.3 From 5e3e425902513c9a013f208c9e374ea322e516c3 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 31 Jan 2024 10:14:58 +0700 Subject: Add image on product variant --- indoteknik_custom/models/solr/product_product.py | 13 +++++++------ indoteknik_custom/models/solr/product_template.py | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) 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, -- cgit v1.2.3