summaryrefslogtreecommitdiff
path: root/fixco_custom/models/stock_picking.py
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-01-09 14:53:34 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-01-09 14:53:34 +0700
commit57dee69f10404610c9b2cac8268f78ebd92a9b19 (patch)
treea5280fb2f04cee2c4359943cb2282999ba666fe1 /fixco_custom/models/stock_picking.py
parentf0fdef1687cf29adb42fbb10512820088d8a9953 (diff)
parent82c1232c08894dad3d6e326649785b5669a12077 (diff)
Merge branch 'main' of https://bitbucket.org/altafixco/fixco-addons into bills_add_item_po
Diffstat (limited to 'fixco_custom/models/stock_picking.py')
-rwxr-xr-xfixco_custom/models/stock_picking.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py
index 76c2ecf..c2d5150 100755
--- a/fixco_custom/models/stock_picking.py
+++ b/fixco_custom/models/stock_picking.py
@@ -68,6 +68,29 @@ class StockPicking(models.Model):
list_product = fields.Char(string='List Product')
is_dispatched = fields.Boolean(string='Is Dispatched', default=False, compute='_compute_is_dispatched', readonly=True)
+ def check_qty_bundling_product(self):
+ for line in self.move_ids_without_package:
+ if '(Bundle Component)' in line.sale_line_id.name:
+ if line.forecast_availability < 1 or line.quantity_done < 1:
+ raise UserError('Barang Bundling : %s Quantity Done tidak boleh 0' % line.product_id.display_name)
+
+ def check_qty_done_stock(self):
+ for line in self.move_line_ids_without_package:
+ def check_qty_per_inventory(self, product, location):
+ quant = self.env['stock.quant'].search([
+ ('product_id', '=', product.id),
+ ('location_id', '=', location.id),
+ ])
+
+ if quant:
+ return quant.quantity
+
+ return 0
+
+ qty_onhand = check_qty_per_inventory(self, line.product_id, line.location_id)
+ if line.qty_done > qty_onhand:
+ raise UserError('Quantity Done melebihi Quantity Onhand')
+
@api.depends('shipment_group_id')
def _compute_is_dispatched(self):
for picking in self:
@@ -122,6 +145,10 @@ class StockPicking(models.Model):
return action
def button_validate(self):
+ if not self.picking_type_code == 'incoming' and not self.name.startswith('BU/IN'):
+ self.check_qty_done_stock()
+ self.check_qty_bundling_product()
+
origin = self.origin or ''
if any(prefix in origin for prefix in ['PO/', 'SO/']) and not self.check_product_lines and not self.name.startswith('BU/INT'):
raise UserError(_("Belum ada check product, gabisa validate"))
@@ -285,6 +312,7 @@ class StockPicking(models.Model):
self.carrier = picking.sale_id.carrier
self.address = picking.sale_id.address
self.note_by_buyer = picking.sale_id.note_by_buyer
+ self.date_deadline = picking.sale_id.deadline_date
self.schema_multi_single_sku()
def schema_multi_single_sku(self):