summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-05-17 11:22:16 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-05-17 11:22:16 +0700
commit9b0ab52b8c1240664567eb8c555dd5d4f3ece677 (patch)
tree29033e9ee379c20a274a8d9a5e49931248203e7b
parent2ab715ecff3ec0a63e5924cc1b3a65741c40b99f (diff)
add validation for prevent bug manufacturing order
-rwxr-xr-xindoteknik_custom/models/__init__.py3
-rw-r--r--indoteknik_custom/models/manufacturing.py34
2 files changed, 36 insertions, 1 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 5dc9ce9e..18f46d34 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -60,4 +60,5 @@ from . import automatic_purchase
from . import apache_solr
from . import raja_ongkir
from . import procurement_monitoring_detail
-from . import brand_vendor \ No newline at end of file
+from . import brand_vendor
+from . import manufacturing
diff --git a/indoteknik_custom/models/manufacturing.py b/indoteknik_custom/models/manufacturing.py
new file mode 100644
index 00000000..e6e6592c
--- /dev/null
+++ b/indoteknik_custom/models/manufacturing.py
@@ -0,0 +1,34 @@
+from odoo import fields, models, api
+from odoo.exceptions import UserError
+import logging
+
+_logger = logging.getLogger(__name__)
+
+class Manufacturing(models.Model):
+ _inherit = 'mrp.production'
+
+ def action_confirm(self):
+ if self._name != 'mrp.production':
+ return super(Manufacturing, self).action_confirm()
+
+ if self.location_src_id.id != 75:
+ raise UserError('Component Location hanya bisa di AS/Stock')
+ elif self.location_dest_id.id != 75:
+ raise UserError('Finished Product Location hanya bisa di AS/Stock')
+
+ result = super(Manufacturing, self).action_confirm()
+ return result
+
+ def button_mark_done(self):
+ if self._name != 'mrp.production':
+ return super(Manufacturing, self).button_mark_done()
+
+ for line in self.move_raw_ids:
+ if line.quantity_done > 0 and line.quantity_done != self.product_uom_qty:
+ raise UserError('Qty Consume per Line tidak sama dengan Qty to Produce')
+ if line.forecast_availability != line.product_uom_qty:
+ raise UserError('Qty Reserved belum sesuai dengan yang seharusnya')
+
+ result = super(Manufacturing, self).button_mark_done()
+ return result
+ \ No newline at end of file