From 03ba190bca443625075ddbd637d895bfc1a27fcd Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 16 Feb 2024 09:55:41 +0700 Subject: Add active field on promotion program line --- indoteknik_custom/models/promotion/promotion_program_line.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index 18a7e184..43daf93b 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -30,6 +30,7 @@ class PromotionProgramLine(models.Model): discount_amount = fields.Float('Discount Amount') order_promotion_ids = fields.One2many('sale.order.promotion', 'program_line_id', 'Promotions') + active = fields.Boolean(default=True) def get_active_promotions(self, product_id): current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') -- cgit v1.2.3 From 3861a02e3080d75b507ad9a763fa7f635b463ec8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 16 Feb 2024 11:43:08 +0700 Subject: Add description on apache solr queue --- indoteknik_custom/models/solr/apache_solr_queue.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 07274295..f8c57919 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -18,6 +18,7 @@ class ApacheSolrQueue(models.Model): ('not_found', 'Record not found') ], 'Execute Status') execute_date = fields.Datetime('Execute Date') + description = fields.Text('Description') def _compute_display_name(self): for rec in self: @@ -57,7 +58,8 @@ class ApacheSolrQueue(models.Model): rec.execute_status = 'success' else: rec.execute_status = 'not_found' - except: + except Exception as e: + rec.description = e rec.execute_status = 'failed' rec.execute_date = datetime.utcnow() self.env.cr.commit() -- cgit v1.2.3 From 078ee431a58dfdfd554d3c9b91c67271f5bcce5c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 16 Feb 2024 13:32:38 +0700 Subject: Delete image on promotion program line --- indoteknik_custom/models/solr/promotion_program_line.py | 1 - 1 file changed, 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 6e182324..cd692ed3 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -41,7 +41,6 @@ class PromotionProgramLine(models.Model): 'id': rec.id, 'program_id_i': rec.program_id.id, 'name_s': rec.name, - 'image_s': self.env['ir.attachment'].api_image(self._name, 'image', rec.id) if rec.image else '', 'type_value_s': promotion_type['value'], 'type_label_s': promotion_type['label'], 'package_limit_i': rec.package_limit, -- cgit v1.2.3 From aa9f502540c7a88643abb49bdca8f3d81257d4ec Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 16 Feb 2024 13:34:08 +0700 Subject: Update program line's program_id to 0 when no parent --- indoteknik_custom/models/solr/promotion_program_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index cd692ed3..edee259f 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -39,7 +39,7 @@ class PromotionProgramLine(models.Model): document.update({ 'id': rec.id, - 'program_id_i': rec.program_id.id, + 'program_id_i': rec.program_id.id or 0, 'name_s': rec.name, 'type_value_s': promotion_type['value'], 'type_label_s': promotion_type['label'], -- cgit v1.2.3 From ad0759513cc296e4a41196b2dccac35885d834e3 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 16 Feb 2024 13:45:52 +0700 Subject: Fix get remaining time on promotion program line --- indoteknik_custom/models/promotion/promotion_program_line.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index 43daf93b..9fab6e58 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -75,6 +75,9 @@ class PromotionProgramLine(models.Model): } def _get_remaining_time(self): + if not self.program_id.end_time: + return 0 + calculate_time = self.program_id.end_time - datetime.now() return round(calculate_time.total_seconds()) -- cgit v1.2.3 From fd275ea8c25246e349ae3e177ac6d0acdda249c6 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 17 Feb 2024 11:13:09 +0700 Subject: Add open target record on apache solr queue --- indoteknik_custom/models/solr/apache_solr_queue.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index f8c57919..02ad5bb8 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -39,6 +39,16 @@ class ApacheSolrQueue(models.Model): if elapsed_time > max_exec_time: break rec.execute_queue() + + def open_target_record(self): + return { + 'name': '', + 'view_mode': 'form', + 'res_model': self.res_model, + 'target': 'current', + 'type': 'ir.actions.act_window', + 'res_id': self.res_id + } def execute_queue(self): for rec in self: -- cgit v1.2.3 From f954856557e5199989f2e83a3d7c3015b5d9d42c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 20 Feb 2024 16:28:57 +0700 Subject: Add parent on promotion product api res --- indoteknik_custom/models/promotion/promotion_free_product.py | 4 ++++ indoteknik_custom/models/promotion/promotion_product.py | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/promotion/promotion_free_product.py b/indoteknik_custom/models/promotion/promotion_free_product.py index c5055562..e91d5137 100644 --- a/indoteknik_custom/models/promotion/promotion_free_product.py +++ b/indoteknik_custom/models/promotion/promotion_free_product.py @@ -17,6 +17,10 @@ class PromotionFreeProduct(models.Model): weight = rec.product_id.weight or 0 result.append({ 'id': rec.product_id.id, + 'parent': { + 'id': rec.product_id.product_tmpl_id.id, + 'name': rec.product_id.product_tmpl_id.name, + }, 'image': ir_attachment.api_image('product.template', 'image_256', rec.product_id.product_tmpl_id.id), 'display_name': rec.product_id.display_name, 'name': rec.product_id.name, diff --git a/indoteknik_custom/models/promotion/promotion_product.py b/indoteknik_custom/models/promotion/promotion_product.py index 2fad0f0d..ae26e888 100644 --- a/indoteknik_custom/models/promotion/promotion_product.py +++ b/indoteknik_custom/models/promotion/promotion_product.py @@ -17,6 +17,10 @@ class PromotionProduct(models.Model): weight = rec.product_id.weight or 0 result.append({ 'id': rec.product_id.id, + 'parent': { + 'id': rec.product_id.product_tmpl_id.id, + 'name': rec.product_id.product_tmpl_id.name, + }, 'image': ir_attachment.api_image('product.template', 'image_256', rec.product_id.product_tmpl_id.id), 'display_name': rec.product_id.display_name, 'name': rec.product_id.name, -- cgit v1.2.3 From c0daeae791b069aa77baad4b19ecd400c75a42d6 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 21 Feb 2024 09:13:09 +0700 Subject: Fix weight on product variant solr --- indoteknik_custom/models/solr/product_product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 5a74df8c..c14f6b98 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -59,7 +59,7 @@ class ProductProduct(models.Model): 'template_id_i': variant.product_tmpl_id.id, '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, + 'weight_f': variant.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 '', -- cgit v1.2.3 From 99df2a863b6d641e96b7dd9fafbed701642d5ca7 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 21 Feb 2024 10:21:01 +0700 Subject: Fix promotion program line weight --- indoteknik_custom/models/promotion/promotion_program_line.py | 4 +--- indoteknik_custom/models/solr/promotion_program_line.py | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/promotion/promotion_program_line.py b/indoteknik_custom/models/promotion/promotion_program_line.py index 9fab6e58..ce46d2e7 100644 --- a/indoteknik_custom/models/promotion/promotion_program_line.py +++ b/indoteknik_custom/models/promotion/promotion_program_line.py @@ -97,9 +97,7 @@ class PromotionProgramLine(models.Model): free_products = self.free_product_ids.formats(purchase_qty=qty) merged_products = products + free_products - weight = 0 - if not any(x['package_weight'] == 0 for x in merged_products): - weight = sum(x['package_weight'] for x in merged_products) + weight = sum(x['package_weight'] for x in merged_products) # Sum of products and free products in 1 package quantity products_total = sum(x['price']['price_discount'] * x['qty'] / qty for x in products) diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index edee259f..30ce16c9 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -52,6 +52,7 @@ class PromotionProgramLine(models.Model): 'free_product_ids': [x.product_id.id for x in rec.free_product_ids], 'free_products_s': json.dumps(free_products), 'total_qty_i': sum([x.qty for x in rec.product_ids] + [x.qty for x in rec.free_product_ids]), + 'active': rec.active }) self.solr().add([document]) -- cgit v1.2.3 From 0face879a802bf1a15d1065d59db64f723b4e8d3 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 21 Feb 2024 16:39:10 +0700 Subject: Fix error post account move --- indoteknik_custom/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index a9db212f..7eb65e9f 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -122,7 +122,7 @@ class AccountMove(models.Model): sum_qty_invoice = sum_qty_order = 0 for line in purchase_order.order_line: sum_qty_invoice += line.qty_invoiced - sum_qty_order += line.product_uom_qty + sum_qty_order += line.product_qty if sum_qty_invoice > sum_qty_order: raise UserError('Error Qty Invoice akan lebih besar dari Qty Order jika lanjut Posting') -- cgit v1.2.3