From fe9056c55bc206a02e52b58baf1881271cf098f8 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Mon, 22 Dec 2025 13:37:48 +0700 Subject: count line in Shipment group --- fixco_custom/models/shipment_group.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'fixco_custom/models') diff --git a/fixco_custom/models/shipment_group.py b/fixco_custom/models/shipment_group.py index aba77f5..3cdba5b 100644 --- a/fixco_custom/models/shipment_group.py +++ b/fixco_custom/models/shipment_group.py @@ -35,6 +35,12 @@ class ShipmentGroup(models.Model): picking_lines = fields.One2many('picking.line', 'shipment_id', string='Picking Lines', auto_join=True) related_count = fields.Integer(compute='_compute_related_count', string='Related Count') receipt = fields.Char(string='Receipt', related='picking_lines.scan_receipt') + total_line = fields.Integer(string='Total Line', compute='_compute_total_line') + + @api.depends('picking_lines') + def _compute_total_line(self): + for rec in self: + rec.total_line = len(rec.picking_lines) def sync_product_to_picking_line(self): for shipment in self: -- cgit v1.2.3 From 175b10a298185a724b7c0f8d0d25beec38b4f0e1 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Mon, 22 Dec 2025 14:43:47 +0700 Subject: add message post when adding and removing product in check product --- fixco_custom/models/stock_picking.py | 47 ++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'fixco_custom/models') diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py index e4ed1b5..5c83ac8 100755 --- a/fixco_custom/models/stock_picking.py +++ b/fixco_custom/models/stock_picking.py @@ -594,6 +594,7 @@ class CheckProduct(models.Model): _name = 'check.product' _description = 'Check Product' _order = 'picking_id, id' + _inherit = ['mail.thread', 'mail.activity.mixin'] picking_id = fields.Many2one( 'stock.picking', @@ -644,29 +645,41 @@ class CheckProduct(models.Model): self.quantity = 1 def unlink(self): - # Get all affected pickings before deletion - pickings = self.mapped('picking_id') + picking_map = {} + for line in self: + picking_map.setdefault(line.picking_id, []).append({ + 'product': line.product_id.display_name, + 'qty': line.quantity, + }) - # Store product_ids that will be deleted + pickings = self.mapped('picking_id') deleted_product_ids = self.mapped('product_id') - # Perform the deletion result = super(CheckProduct, self).unlink() - # After deletion, update moves for affected pickings for picking in pickings: - # For products that were completely removed (no remaining check.product lines) + if picking in picking_map: + product_list = picking_map[picking] + + picking.message_post( + body=( + "Product Dihapus dari Check Product
" + "%s" + ) % "
".join( + "- %s" % product for product in product_list + ), + subtype_xmlid='mail.mt_note', + ) + remaining_product_ids = picking.check_product_lines.mapped('product_id') removed_product_ids = deleted_product_ids - remaining_product_ids - # Set quantity_done to 0 for moves of completely removed products moves_to_reset = picking.move_ids_without_package.filtered( lambda move: move.product_id in removed_product_ids ) for move in moves_to_reset: move.quantity_done = 0.0 - # Also sync remaining products in case their totals changed self._sync_check_product_to_moves(picking) return result @@ -684,12 +697,26 @@ class CheckProduct(models.Model): else: record.status = 'Done' + + @api.model def create(self, vals): - # Create the record record = super(CheckProduct, self).create(vals) - # Ensure uniqueness after creation + + if record.product_id and record.picking_id: + record.picking_id.message_post( + body=( + "Check Product Berhasil
" + "Product: %s
" + ) % ( + record.product_id.display_name, + ), + message_type='comment', + subtype_xmlid='mail.mt_note', + ) + if not self.env.context.get('skip_consolidate'): record.with_context(skip_consolidate=True)._consolidate_duplicate_lines() + return record def write(self, vals): -- cgit v1.2.3