From cdeceb0e5325b00a1239470ab3493d84edd8328d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 27 Aug 2025 10:36:39 +0700 Subject: fix res partner --- indoteknik_custom/models/res_partner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 1dba200a..7a714ea7 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -279,11 +279,12 @@ class ResPartner(models.Model): if record.name: existing_partner = self.env['res.partner'].search([ ('id', '!=', record.id), + '|', ('name', '=', record.name), ('email', '=', record.email) ], limit=1) - if existing_partner: + if existing_partner and not record.parent_id: raise ValidationError(f"Nama '{record.name}' dengan email '{record.email}' sudah digunakan oleh partner lain!") @api.constrains('npwp') -- cgit v1.2.3 From 2103a438acc24ad44965b869a28a15424838c9b5 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Wed, 27 Aug 2025 13:39:59 +0700 Subject: (andri) 1. add sum open amount & add field amount total SO pada DE, 2. sum total amount pada dunning run --- indoteknik_custom/models/account_move_due_extension.py | 15 +++++++++++++++ indoteknik_custom/views/account_move_views.xml | 3 ++- indoteknik_custom/views/dunning_run.xml | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/account_move_due_extension.py b/indoteknik_custom/models/account_move_due_extension.py index d354e3e3..40059bd9 100644 --- a/indoteknik_custom/models/account_move_due_extension.py +++ b/indoteknik_custom/models/account_move_due_extension.py @@ -14,6 +14,16 @@ class DueExtension(models.Model): number = fields.Char(string='Document No', index=True, copy=False, readonly=True, tracking=True) partner_id = fields.Many2one('res.partner', string="Customer", readonly=True) order_id = fields.Many2one('sale.order', string="SO", readonly=True) + amount_total = fields.Monetary( + string="Amount Total SO", + compute="_compute_amount_total", + readonly=True + ) + currency_id = fields.Many2one( + 'res.currency', + related="order_id.currency_id", + readonly=True + ) invoice_id = fields.Many2one('account.move', related='due_line.invoice_id', string='Invoice', readonly=False) due_line = fields.One2many('due.extension.line', 'due_id', string='Due Extension Lines', auto_join=True) old_due = fields.Date(string="Old Due") @@ -34,6 +44,11 @@ class DueExtension(models.Model): approve_by = fields.Many2one('res.users', string="Approve By", readonly=True) date_approve = fields.Datetime(string="Date Approve", readonly=True) + @api.depends('order_id') + def _compute_amount_total(self): + for rec in self: + rec.amount_total = rec.order_id.amount_total if rec.order_id else 0.0 + def _compute_counter(self): for due in self: due.counter = due.partner_id.counter diff --git a/indoteknik_custom/views/account_move_views.xml b/indoteknik_custom/views/account_move_views.xml index 0fd7c9cd..7c1f8913 100644 --- a/indoteknik_custom/views/account_move_views.xml +++ b/indoteknik_custom/views/account_move_views.xml @@ -33,7 +33,7 @@ - + @@ -68,6 +68,7 @@ + diff --git a/indoteknik_custom/views/dunning_run.xml b/indoteknik_custom/views/dunning_run.xml index 2117a7bb..210f7917 100644 --- a/indoteknik_custom/views/dunning_run.xml +++ b/indoteknik_custom/views/dunning_run.xml @@ -29,7 +29,7 @@ - + -- cgit v1.2.3 From 491a66b7245379c23d0555c29d0d9d7861013144 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 27 Aug 2025 14:53:49 +0700 Subject: sum total qty sold --- indoteknik_custom/models/solr/promotion_program_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 64ad4209..4eafb9ac 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -64,7 +64,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]), - 'total_qty_sold_f': [x.product_id.qty_sold for x in rec.product_ids], + 'total_qty_sold_f': sum([x.product_id.qty_sold for x in rec.product_ids]), 'active_b': rec.active, "manufacture_name_s": rec.product_ids.product_id.x_manufacture.x_name or '', "category_name": category_names, -- cgit v1.2.3 From 9add83a67fb62b20db56750f3d318debb84ea5e5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 27 Aug 2025 15:29:24 +0700 Subject: fix bug res partner duplicate email and name --- indoteknik_custom/models/res_partner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 7a714ea7..148a3fd0 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -279,7 +279,6 @@ class ResPartner(models.Model): if record.name: existing_partner = self.env['res.partner'].search([ ('id', '!=', record.id), - '|', ('name', '=', record.name), ('email', '=', record.email) ], limit=1) -- cgit v1.2.3 From fbf4071010149637fed008c581424137577ee67f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 27 Aug 2025 15:36:54 +0700 Subject: fix bug program line --- indoteknik_custom/models/solr/promotion_program_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 4eafb9ac..64ad4209 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -64,7 +64,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]), - 'total_qty_sold_f': sum([x.product_id.qty_sold for x in rec.product_ids]), + 'total_qty_sold_f': [x.product_id.qty_sold for x in rec.product_ids], 'active_b': rec.active, "manufacture_name_s": rec.product_ids.product_id.x_manufacture.x_name or '', "category_name": category_names, -- cgit v1.2.3 From 1788dc7a4142f69e076891267d6e0567edd02d2f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 27 Aug 2025 15:47:28 +0700 Subject: add error log --- .../models/solr/promotion_program_line.py | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 64ad4209..a7459521 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -2,6 +2,9 @@ from odoo import models, api from typing import Type import pysolr import json +import logging + +_logger = logging.getLogger(__name__) class PromotionProgramLine(models.Model): _inherit = 'promotion.program.line' @@ -19,9 +22,9 @@ class PromotionProgramLine(models.Model): }) def _sync_to_solr(self): - solr_model = self.env['apache.solr'] - - for rec in self: + solr_model = self.env['apache.solr'] + for rec in self: + try: document = solr_model.get_doc(self._solr_schema, rec.id) products = [{ @@ -37,10 +40,7 @@ class PromotionProgramLine(models.Model): promotion_type = rec._res_promotion_type() - # Gathering all categories category_names = [category.name for category in rec.product_ids.product_id.public_categ_ids] - - # Set sequence_i to None if rec.sequence is 0 sequence_value = None if rec.sequence == 0 else rec.sequence document.update({ @@ -71,7 +71,16 @@ class PromotionProgramLine(models.Model): }) self.solr().add([document]) - self.solr().commit() + self.solr().commit() + + except Exception as e: + _logger.error( + "Failed to sync record %s (ID: %s) to Solr. Error: %s", + rec._name, rec.id, str(e), + exc_info=True # biar stack trace keluar + ) + # opsional -> kalau mau hard fail: + # raise UserError(_("Sync to Solr failed for record %s: %s") % (rec.name, str(e))) @api.model def create(self, vals): -- cgit v1.2.3 From 97c13d37545bf30a39c4e2ba96928daa441acf51 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 27 Aug 2025 15:49:37 +0700 Subject: fix bug --- .../models/solr/promotion_program_line.py | 118 ++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index a7459521..b4e82a36 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -22,65 +22,65 @@ class PromotionProgramLine(models.Model): }) def _sync_to_solr(self): - solr_model = self.env['apache.solr'] - for rec in self: - try: - document = solr_model.get_doc(self._solr_schema, rec.id) - - products = [{ - 'product_id': x.product_id.id, - 'qty': x.qty, - 'qty_sold': x.product_id.qty_sold - } for x in rec.product_ids] - - free_products = [{ - 'product_id': x.product_id.id, - 'qty': x.qty - } for x in rec.free_product_ids] - - promotion_type = rec._res_promotion_type() - - category_names = [category.name for category in rec.product_ids.product_id.public_categ_ids] - sequence_value = None if rec.sequence == 0 else rec.sequence - - document.update({ - 'id': rec.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'], - 'package_limit_i': rec.package_limit, - 'package_limit_user_i': rec.package_limit_user, - 'package_limit_trx_i': rec.package_limit_trx, - 'price_f': rec.price, - 'price_tier_1_f': rec.price_tier_1, - 'price_tier_2_f': rec.price_tier_2, - 'price_tier_3_f': rec.price_tier_3, - 'price_tier_4_f': rec.price_tier_4, - 'price_tier_5_f': rec.price_tier_5, - 'sequence_i': sequence_value, - 'product_ids': [x.product_id.id for x in rec.product_ids], - 'products_s': json.dumps(products), - '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]), - 'total_qty_sold_f': [x.product_id.qty_sold for x in rec.product_ids], - 'active_b': rec.active, - "manufacture_name_s": rec.product_ids.product_id.x_manufacture.x_name or '', - "category_name": category_names, - }) - - self.solr().add([document]) - self.solr().commit() - - except Exception as e: - _logger.error( - "Failed to sync record %s (ID: %s) to Solr. Error: %s", - rec._name, rec.id, str(e), - exc_info=True # biar stack trace keluar - ) - # opsional -> kalau mau hard fail: - # raise UserError(_("Sync to Solr failed for record %s: %s") % (rec.name, str(e))) + solr_model = self.env['apache.solr'] + for rec in self: + try: + document = solr_model.get_doc(self._solr_schema, rec.id) + + products = [{ + 'product_id': x.product_id.id, + 'qty': x.qty, + 'qty_sold': x.product_id.qty_sold + } for x in rec.product_ids] + + free_products = [{ + 'product_id': x.product_id.id, + 'qty': x.qty + } for x in rec.free_product_ids] + + promotion_type = rec._res_promotion_type() + + category_names = [category.name for category in rec.product_ids.product_id.public_categ_ids] + sequence_value = None if rec.sequence == 0 else rec.sequence + + document.update({ + 'id': rec.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'], + 'package_limit_i': rec.package_limit, + 'package_limit_user_i': rec.package_limit_user, + 'package_limit_trx_i': rec.package_limit_trx, + 'price_f': rec.price, + 'price_tier_1_f': rec.price_tier_1, + 'price_tier_2_f': rec.price_tier_2, + 'price_tier_3_f': rec.price_tier_3, + 'price_tier_4_f': rec.price_tier_4, + 'price_tier_5_f': rec.price_tier_5, + 'sequence_i': sequence_value, + 'product_ids': [x.product_id.id for x in rec.product_ids], + 'products_s': json.dumps(products), + '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]), + 'total_qty_sold_f': [x.product_id.qty_sold for x in rec.product_ids], + 'active_b': rec.active, + "manufacture_name_s": rec.product_ids.product_id.x_manufacture.x_name or '', + "category_name": category_names, + }) + + self.solr().add([document]) + self.solr().commit() + + except Exception as e: + _logger.error( + "Failed to sync record %s (ID: %s) to Solr. Error: %s", + rec._name, rec.id, str(e), + exc_info=True # biar stack trace keluar + ) + # opsional -> kalau mau hard fail: + # raise UserError(_("Sync to Solr failed for record %s: %s") % (rec.name, str(e))) @api.model def create(self, vals): -- cgit v1.2.3 From e8c10203b9cac4e8fe020a56f39945fbd360b605 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 27 Aug 2025 16:08:46 +0700 Subject: bug solr --- .../models/solr/promotion_program_line.py | 111 ++++++++++----------- 1 file changed, 51 insertions(+), 60 deletions(-) diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index b4e82a36..64ad4209 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -2,9 +2,6 @@ from odoo import models, api from typing import Type import pysolr import json -import logging - -_logger = logging.getLogger(__name__) class PromotionProgramLine(models.Model): _inherit = 'promotion.program.line' @@ -23,64 +20,58 @@ class PromotionProgramLine(models.Model): def _sync_to_solr(self): solr_model = self.env['apache.solr'] + for rec in self: - try: - document = solr_model.get_doc(self._solr_schema, rec.id) - - products = [{ - 'product_id': x.product_id.id, - 'qty': x.qty, - 'qty_sold': x.product_id.qty_sold - } for x in rec.product_ids] - - free_products = [{ - 'product_id': x.product_id.id, - 'qty': x.qty - } for x in rec.free_product_ids] - - promotion_type = rec._res_promotion_type() - - category_names = [category.name for category in rec.product_ids.product_id.public_categ_ids] - sequence_value = None if rec.sequence == 0 else rec.sequence - - document.update({ - 'id': rec.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'], - 'package_limit_i': rec.package_limit, - 'package_limit_user_i': rec.package_limit_user, - 'package_limit_trx_i': rec.package_limit_trx, - 'price_f': rec.price, - 'price_tier_1_f': rec.price_tier_1, - 'price_tier_2_f': rec.price_tier_2, - 'price_tier_3_f': rec.price_tier_3, - 'price_tier_4_f': rec.price_tier_4, - 'price_tier_5_f': rec.price_tier_5, - 'sequence_i': sequence_value, - 'product_ids': [x.product_id.id for x in rec.product_ids], - 'products_s': json.dumps(products), - '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]), - 'total_qty_sold_f': [x.product_id.qty_sold for x in rec.product_ids], - 'active_b': rec.active, - "manufacture_name_s": rec.product_ids.product_id.x_manufacture.x_name or '', - "category_name": category_names, - }) - - self.solr().add([document]) - self.solr().commit() - - except Exception as e: - _logger.error( - "Failed to sync record %s (ID: %s) to Solr. Error: %s", - rec._name, rec.id, str(e), - exc_info=True # biar stack trace keluar - ) - # opsional -> kalau mau hard fail: - # raise UserError(_("Sync to Solr failed for record %s: %s") % (rec.name, str(e))) + document = solr_model.get_doc(self._solr_schema, rec.id) + + products = [{ + 'product_id': x.product_id.id, + 'qty': x.qty, + 'qty_sold': x.product_id.qty_sold + } for x in rec.product_ids] + + free_products = [{ + 'product_id': x.product_id.id, + 'qty': x.qty + } for x in rec.free_product_ids] + + promotion_type = rec._res_promotion_type() + + # Gathering all categories + category_names = [category.name for category in rec.product_ids.product_id.public_categ_ids] + + # Set sequence_i to None if rec.sequence is 0 + sequence_value = None if rec.sequence == 0 else rec.sequence + + document.update({ + 'id': rec.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'], + 'package_limit_i': rec.package_limit, + 'package_limit_user_i': rec.package_limit_user, + 'package_limit_trx_i': rec.package_limit_trx, + 'price_f': rec.price, + 'price_tier_1_f': rec.price_tier_1, + 'price_tier_2_f': rec.price_tier_2, + 'price_tier_3_f': rec.price_tier_3, + 'price_tier_4_f': rec.price_tier_4, + 'price_tier_5_f': rec.price_tier_5, + 'sequence_i': sequence_value, + 'product_ids': [x.product_id.id for x in rec.product_ids], + 'products_s': json.dumps(products), + '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]), + 'total_qty_sold_f': [x.product_id.qty_sold for x in rec.product_ids], + 'active_b': rec.active, + "manufacture_name_s": rec.product_ids.product_id.x_manufacture.x_name or '', + "category_name": category_names, + }) + + self.solr().add([document]) + self.solr().commit() @api.model def create(self, vals): -- cgit v1.2.3