From af483feb734c1e135a779008ca3fa32a721d59ff Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 20 Aug 2025 15:24:58 +0700 Subject: fix bug percent pie --- indoteknik_custom/models/sale_order.py | 35 +++++++++++++++++------------ indoteknik_custom/models/sale_order_line.py | 23 +++++++++++-------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 53be999f..5787c6ea 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -431,21 +431,27 @@ class SaleOrder(models.Model): continue for move in line.move_ids: - if move.state != 'done': - # reserve qty (draft/assigned) - if move.picking_type_id.code == 'internal': + if move.picking_type_id.code == 'internal': + if move.state != 'done': + # PICK belum done → qty reserved reserved_qty += move.reserved_availability or 0.0 - continue - - # sudah done → cek alur lokasi - if move.location_dest_id.usage == 'customer': - # barang keluar → delivered - delivered_qty += move.quantity_done - elif move.location_id.usage == 'customer': - # barang balik (return) → kurangi delivered - delivered_qty -= move.quantity_done - - # clamp biar ga minus + else: + # PICK done → qty_done masih dianggap reserved (masuk BU/OUT) + reserved_qty += move.quantity_done or 0.0 + + elif move.state == 'done': + # OUT done (customer terima) → delivered + if move.location_dest_id.usage == 'customer': + delivered_qty += move.quantity_done + # sekaligus kurangi reserved (karena udah terkirim) + reserved_qty -= move.quantity_done + # Return dari customer + elif move.location_id.usage == 'customer': + delivered_qty -= move.quantity_done + reserved_qty += move.quantity_done # balik ke reserved + + # clamp jangan sampai minus + reserved_qty = max(reserved_qty, 0) delivered_qty = max(delivered_qty, 0) order.reserved_percent = (reserved_qty / total_qty) * 100 @@ -455,6 +461,7 @@ class SaleOrder(models.Model): order.reserved_percent = order.delivered_percent = order.unreserved_percent = 0 + def _has_ccm(self): if self.id: self.ccm_id = self.env['tukar.guling'].search([('origin', 'ilike', self.name)], limit=1) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 2406995d..a20f93ef 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -66,21 +66,29 @@ class SaleOrderLine(models.Model): if order_qty > 0: for move in line.move_ids: + # --- CASE 1: Picking belum done --- if move.state != 'done': - # Reserve qty (hanya dari picking internal yang belum selesai) if move.picking_type_id.code == 'internal': reserved_qty += move.reserved_availability or 0.0 continue - # Kalau sudah done → cek lokasi - if move.location_dest_id.usage == 'customer': - # Barang keluar → tambah delivered + # --- CASE 2: Picking sudah done --- + if move.picking_type_id.code == 'internal': + # PICK done → qty_done tetap dianggap reserved (masih nunggu OUT) + reserved_qty += move.quantity_done or 0.0 + + elif move.location_dest_id.usage == 'customer': + # OUT done (barang nyampe customer) delivered_qty += move.quantity_done + reserved_qty -= move.quantity_done + elif move.location_id.usage == 'customer': - # Barang balik dari customer (retur) → kurangi delivered + # Retur dari customer delivered_qty -= move.quantity_done + reserved_qty += move.quantity_done - # Jangan sampai delivered minus + # clamp supaya gak minus + reserved_qty = max(reserved_qty, 0) delivered_qty = max(delivered_qty, 0) # Hitung persentase @@ -88,9 +96,6 @@ class SaleOrderLine(models.Model): line.delivered_percent = (delivered_qty / order_qty) * 100 if order_qty else 0 line.unreserved_percent = 100 - line.reserved_percent - line.delivered_percent - - - def _get_outgoing_incoming_moves(self): outgoing_moves = self.env['stock.move'] incoming_moves = self.env['stock.move'] -- cgit v1.2.3 From 3b4e4c77f0f0f83f3c739cd10c6e476c4dc39e7d Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 20 Aug 2025 15:26:43 +0700 Subject: Bug Invoice CCM --- indoteknik_custom/models/tukar_guling.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index 4b03d4b0..23b9f085 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -109,9 +109,6 @@ class TukarGuling(models.Model): ('invoice_line_ids.product_id', 'in', product_ids), ] - if rec.partner_id: - domain.append(('partner_id', '=', rec.partner_id.id)) - extra = [] if rec.origin: extra.append(('invoice_origin', 'ilike', rec.origin)) -- cgit v1.2.3 From 398945636b3318ed02749f63028f8f76d2d2060d Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 20 Aug 2025 16:19:08 +0700 Subject: Fix Check Product Speed --- indoteknik_custom/static/src/js/check_product_barcode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/static/src/js/check_product_barcode.js b/indoteknik_custom/static/src/js/check_product_barcode.js index f7a1bb75..593b8a5b 100644 --- a/indoteknik_custom/static/src/js/check_product_barcode.js +++ b/indoteknik_custom/static/src/js/check_product_barcode.js @@ -4,7 +4,7 @@ odoo.define('indoteknik_custom.prevent_manual_typing', function (require) { console.log("✅ Custom JS from indoteknik_custom loaded!"); - const THRESHOLD_MS = 40; // jeda antar karakter dianggap scanner kalau <40ms + const THRESHOLD_MS = 100; let lastTime = 0; let burstCount = 0; @@ -16,7 +16,7 @@ odoo.define('indoteknik_custom.prevent_manual_typing', function (require) { } else { burstCount = 1; } - return burstCount >= 3; // setelah 3 char cepat, dianggap scanner + return burstCount >= 2; // setelah 3 char cepat, dianggap scanner } document.addEventListener('keydown', function (e) { -- cgit v1.2.3 From c837117a771bbefcf06706d024d4620b331192a9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 20 Aug 2025 16:20:28 +0700 Subject: push --- indoteknik_custom/models/sale_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 5787c6ea..9a6f314d 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -391,9 +391,9 @@ class SaleOrder(models.Model): payment_state_custom = fields.Selection([ ('unpaid', 'Unpaid'), ('partial', 'Partially Paid'), - ('paid', 'Paid'), + ('paid', 'Full Paid'), ('no_invoice', 'No Invoice'), - ], string="Payment Status", compute="_compute_payment_state_custom", store=False) + ], string="Payment Status Invoice", compute="_compute_payment_state_custom", store=False) @api.depends('invoice_ids.payment_state', 'invoice_ids.amount_total', 'invoice_ids.amount_residual') def _compute_payment_state_custom(self): -- cgit v1.2.3 From 6d62c215f1c9bd3b76715d4de0367bf4dd2b4363 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 20 Aug 2025 17:06:59 +0700 Subject: Fix check product barcode --- indoteknik_custom/static/src/js/check_product_barcode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/static/src/js/check_product_barcode.js b/indoteknik_custom/static/src/js/check_product_barcode.js index 593b8a5b..aedba34d 100644 --- a/indoteknik_custom/static/src/js/check_product_barcode.js +++ b/indoteknik_custom/static/src/js/check_product_barcode.js @@ -4,7 +4,7 @@ odoo.define('indoteknik_custom.prevent_manual_typing', function (require) { console.log("✅ Custom JS from indoteknik_custom loaded!"); - const THRESHOLD_MS = 100; + const THRESHOLD_MS = 250; let lastTime = 0; let burstCount = 0; -- cgit v1.2.3 From 919af07c186c43f2e9f41c005d2ba16aa5e8596d Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 21 Aug 2025 08:49:46 +0700 Subject: Unblock --- indoteknik_custom/__manifest__.py | 4 ++-- indoteknik_custom/models/stock_picking.py | 17 ----------------- .../static/src/js/check_product_barcode.js | 4 ++-- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 85603a33..95989c79 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -8,10 +8,10 @@ 'author': 'Rafi Zadanly', 'website': '', 'images': ['assets/favicon.ico'], - 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'vit_kelurahan', 'vit_efaktur', 'barcodes'], + 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'vit_kelurahan', 'vit_efaktur'], 'data': [ 'security/ir.model.access.csv', - 'views/assets.xml', + # 'views/assets.xml', 'views/group_partner.xml', 'views/blog_post.xml', 'views/coupon_program.xml', diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 423cbb0a..7e970c5d 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -2072,8 +2072,6 @@ class CheckProduct(models.Model): _name = 'check.product' _description = 'Check Product' _order = 'picking_id, id' - _inherit = ['barcodes.barcode_events_mixin'] # ⬅️ aktifkan barcode handler - picking_id = fields.Many2one( 'stock.picking', @@ -2088,21 +2086,6 @@ class CheckProduct(models.Model): status = fields.Char(string='Status', compute='_compute_status') code_product = fields.Char(string='Code Product') - def write(self, vals): - if 'code_product' in vals and not self.env.context.get('from_barcode_scan'): - raise UserError("Field Code Product hanya bisa diisi melalui barcode scan.") - res = super().write(vals) - # konsolidasi dll milik Anda tetap jalan - if not self.env.context.get('skip_consolidate'): - self.with_context(skip_consolidate=True)._consolidate_duplicate_lines() - return res - - # Scanner handler - def on_barcode_scanned(self, barcode): - self.ensure_one() - self.with_context(from_barcode_scan=True).write({'code_product': barcode}) - self._onchange_code_product() - @api.onchange('code_product') def _onchange_code_product(self): if not self.code_product: diff --git a/indoteknik_custom/static/src/js/check_product_barcode.js b/indoteknik_custom/static/src/js/check_product_barcode.js index aedba34d..9da41479 100644 --- a/indoteknik_custom/static/src/js/check_product_barcode.js +++ b/indoteknik_custom/static/src/js/check_product_barcode.js @@ -4,7 +4,7 @@ odoo.define('indoteknik_custom.prevent_manual_typing', function (require) { console.log("✅ Custom JS from indoteknik_custom loaded!"); - const THRESHOLD_MS = 250; + const THRESHOLD_MS = 300; let lastTime = 0; let burstCount = 0; @@ -16,7 +16,7 @@ odoo.define('indoteknik_custom.prevent_manual_typing', function (require) { } else { burstCount = 1; } - return burstCount >= 2; // setelah 3 char cepat, dianggap scanner + return burstCount >= 2; } document.addEventListener('keydown', function (e) { -- cgit v1.2.3