diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-08-21 09:10:12 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-08-21 09:10:12 +0700 |
| commit | d235175fba927ce59461978a5c786a018c6be62a (patch) | |
| tree | 183342fc995607cc32c19495f1245f4e3a35cbb0 | |
| parent | a6592c9b788fe366fc2780af40175805bab6b75c (diff) | |
| parent | 919af07c186c43f2e9f41c005d2ba16aa5e8596d (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 39 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 23 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 17 | ||||
| -rw-r--r-- | indoteknik_custom/models/tukar_guling.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/static/src/js/check_product_barcode.js | 4 |
6 files changed, 41 insertions, 49 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/sale_order.py b/indoteknik_custom/models/sale_order.py index 53be999f..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): @@ -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'] 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/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)) diff --git a/indoteknik_custom/static/src/js/check_product_barcode.js b/indoteknik_custom/static/src/js/check_product_barcode.js index f7a1bb75..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 = 40; // jeda antar karakter dianggap scanner kalau <40ms + 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 >= 3; // setelah 3 char cepat, dianggap scanner + return burstCount >= 2; } document.addEventListener('keydown', function (e) { |
