From 29a64fa64c72c4cb263806b099775a18124a5da7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 14 Mar 2025 08:34:52 +0700 Subject: cr md bom --- indoteknik_custom/models/sale_order.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 14a8e688..b311abda 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1,3 +1,5 @@ +from re import search + from odoo import fields, models, api, _ from odoo.exceptions import UserError, ValidationError from datetime import datetime, timedelta @@ -978,8 +980,20 @@ class SaleOrder(models.Model): raise UserError("Customer Reference kosong, di isi dengan NO PO jika PO tidak ada mohon ditulis Tanpa PO") if not order.user_id.active: raise UserError("Salesperson sudah tidak aktif, mohon diisi yang benar pada data SO dan Contact") - + + 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") + else: + if search_bom.state != 'confirmed': + 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() self.check_limit_so_to_invoice() if self.validate_different_vendor() and not self.vendor_approval: -- cgit v1.2.3