diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-11-19 14:49:01 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-11-19 14:49:01 +0700 |
| commit | bb2be920076aabc49b4f9fdd896d14e096e633eb (patch) | |
| tree | 588196ba53fb7e41d96a61272bdb74b4821fe661 /indoteknik_custom/models/purchase_order.py | |
| parent | 9c4f131ffaf37ca47a78b320a68f7de4e846ecfb (diff) | |
| parent | 58623e9509789381dbe334969de647b4ad0302a4 (diff) | |
Merge branch 'odoo-backup' into locatorlocator
# Conflicts:
# indoteknik_custom/models/__init__.py
# indoteknik_custom/models/stock_move.py
# indoteknik_custom/security/ir.model.access.csv
# indoteknik_custom/views/stock_picking.xml
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: |
