summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindoteknik_custom/models/sale_order.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index b311abda..aed0c1df 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -984,14 +984,14 @@ class SaleOrder(models.Model):
def check_product_bom(self):
for order in self:
for line in order.order_line:
- if 'bom' in line.product_id.default_code:
- search_bom = self.env['mrp.production'].search([('product_id', '=', line.id)], limit=1,)
- if not search_bom:
- raise UserError("Product BOM belum ada di manufacturing orders, silahkan hubungi MD")
+ if 'bom' in line.product_id.default_code.lower() or 'bom-it' in line.name.lower():
+ search_bom = self.env['mrp.production'].search([('product_id', '=', line.product_id.id)],order='name desc')
+ if search_bom:
+ confirmed_bom = search_bom.filtered(lambda x: x.state == 'confirmed')
+ if not confirmed_bom:
+ raise UserError("Product BOM belum dikonfirmasi di Manufacturing Orders. Silakan hubungi MD.")
else:
- if search_bom.state != 'confirmed':
- raise UserError("Product BOM belum di confirm di manufacturing orders, silahkan hubungi MD")
-
+ raise UserError("Product BOM belum di confirm di manufacturing orders, silahkan hubungi MD")
def sale_order_approve(self):
self.check_product_bom()
self.check_credit_limit()