diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-03-14 08:34:52 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-03-14 08:34:52 +0700 |
| commit | 29a64fa64c72c4cb263806b099775a18124a5da7 (patch) | |
| tree | efd78bc27676ccdec95e9a0ec4f9c400cb54fd67 | |
| parent | 0459c5c45d5b29aa63c00686bd500310c13e78bf (diff) | |
<iman> cr md bom
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 16 |
1 files changed, 15 insertions, 1 deletions
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: |
