summaryrefslogtreecommitdiff
path: root/fixco_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-12-24 14:08:25 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-12-24 14:08:25 +0700
commit1c42785d665f1b4d459e468d9c0428bc6f767954 (patch)
tree66018f0a196315f3e4c116064d1f331c092662d5 /fixco_custom/models
parent5dc0eb722ba306ed2e81acad1b6ba7457717af44 (diff)
parent95bcefaef503bcbe787f71ff0aadd2aa2faa47d5 (diff)
Merge branch 'main' of bitbucket.org:altafixco/fixco-addons
merge
Diffstat (limited to 'fixco_custom/models')
-rw-r--r--fixco_custom/models/shipment_group.py6
-rwxr-xr-xfixco_custom/models/stock_picking.py47
2 files changed, 43 insertions, 10 deletions
diff --git a/fixco_custom/models/shipment_group.py b/fixco_custom/models/shipment_group.py
index a2d90f0..01e0f6b 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:
diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py
index 07425d2..6850b1e 100755
--- a/fixco_custom/models/stock_picking.py
+++ b/fixco_custom/models/stock_picking.py
@@ -645,6 +645,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',
@@ -695,29 +696,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=(
+ "<b>Product Dihapus dari Check Product</b><br/>"
+ "%s"
+ ) % "<br/>".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
@@ -735,12 +748,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=(
+ "<b>Check Product Berhasil</b><br/>"
+ "Product: %s<br/>"
+ ) % (
+ 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):