summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-10 11:10:50 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-10 11:10:50 +0700
commit5005eebb8fdd82db1e65a1d3de715d8bb5a63b32 (patch)
tree3d1e2c2ad6ef35f7069116584e90e624551b8024
parent893fbb7a4d1467686c4de435393f1162c4d04bd7 (diff)
IU minus inventory validation
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rwxr-xr-xindoteknik_custom/models/purchase_order.py2
-rw-r--r--indoteknik_custom/models/stock_picking.py13
-rw-r--r--indoteknik_custom/models/stock_quant.py8
4 files changed, 24 insertions, 0 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index e984d0dd..76387ff8 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -97,3 +97,4 @@ from . import sale_advance_payment_inv
from . import purchase_order_multi_update
from . import invoice_reklas_penjualan
from . import purchase_order_multi_confirm
+from . import stock_quant
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 3c446fa7..b1dde1d5 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -54,6 +54,8 @@ class PurchaseOrder(models.Model):
def delete_line(self):
lines_to_delete = self.order_line.filtered(lambda line: line.delete_line)
+ if not lines_to_delete:
+ raise UserError('Tidak ada item yang dipilih')
lines_to_delete.unlink()
def open_form_multi_confirm_po(self):
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index a5e533b1..0c810ef7 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -281,6 +281,17 @@ class StockPicking(models.Model):
self.is_internal_use = self.picking_type_id.is_internal_use
return
+ def validation_minus_onhand_quantity(self):
+ bu_location_id = 57
+ for line in self.move_line_ids_without_package:
+ quant = self.env['stock.quant'].search([
+ ('product_id', '=', line.product_id.id),
+ ('location_id', '=', bu_location_id)
+ ])
+
+ if quant and quant.inventory_quantity < line.product_uom_qty:
+ raise UserError('Quantity reserved lebih besar dari quantity onhand di product')
+
def button_validate(self):
if self._name != 'stock.picking':
return super(StockPicking, self).button_validate()
@@ -314,6 +325,8 @@ class StockPicking(models.Model):
if not self.date_reserved:
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
self.date_reserved = current_time
+
+ self.validation_minus_onhand_quantity()
res = super(StockPicking, self).button_validate()
self.calculate_line_no()
diff --git a/indoteknik_custom/models/stock_quant.py b/indoteknik_custom/models/stock_quant.py
new file mode 100644
index 00000000..9affcf4b
--- /dev/null
+++ b/indoteknik_custom/models/stock_quant.py
@@ -0,0 +1,8 @@
+import logging
+
+from odoo import _, api, fields, models
+from odoo.exceptions import UserError
+class StockQuant(models.Model):
+ _inherit = 'stock.quant'
+
+ \ No newline at end of file