diff options
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index e79417aa..3312e7fd 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -7,6 +7,8 @@ from pytz import timezone, utc import io import base64 from odoo.tools import lazy_property +import socket + try: from odoo.tools.misc import xlsxwriter except ImportError: @@ -120,7 +122,13 @@ class PurchaseOrder(models.Model): string='Show Description', default=True ) - + + @staticmethod + def is_local_env(): + hostname = socket.gethostname().lower() + keywords = ['andri', 'miqdad', 'fin', 'stephan', 'hafid', 'nathan'] + return any(keyword in hostname for keyword in keywords) + @api.onchange('show_description') def onchange_show_description(self): if self.show_description == True: @@ -1043,7 +1051,7 @@ class PurchaseOrder(models.Model): # test = line.product_uom_qty # test2 = line.product_id.plafon_qty # test3 = test2 + line.product_uom_qty - if line.product_uom_qty > line.product_id.plafon_qty + line.product_uom_qty and not self.env.user.id == 21: + if line.product_uom_qty > line.product_id.plafon_qty + line.product_uom_qty and self.env.user.id not in [21, 7]: raise UserError('Product '+line.product_id.name+' melebihi plafon, harus Approval Rafly') def check_different_vendor_so_po(self): @@ -1123,6 +1131,8 @@ class PurchaseOrder(models.Model): if not self.not_update_purchasepricelist: self.add_product_to_pricelist() for line in self.order_line: + if line.product_id.type == 'product' and not line.product_id.categ_id: + raise UserError("Product %s kategorinya kosong" % line.product_id.name) if not line.product_id.purchase_ok: raise UserError("Terdapat barang yang tidak bisa diproses") # Validasi pajak @@ -1137,6 +1147,9 @@ class PurchaseOrder(models.Model): break if send_email: + if self.is_local_env(): + _logger.warning("📪 Local environment detected — skip sending email reminders.") + return self._send_mail() if self.revisi_po: |
