summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFIN-IT_AndriFP <it@fixcomart.co.id>2025-11-18 10:16:15 +0700
committerFIN-IT_AndriFP <it@fixcomart.co.id>2025-11-18 10:16:15 +0700
commitace5065eecb5bcf7072668c88829306dd9b4548a (patch)
tree851e93841d409a997122e91195a42300642c0098
parent696a0ef4e25abd39a013503694be11ca2b0645ca (diff)
parent6074d548889ea0bcd489fcc6642eeaec1422cf89 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
-rw-r--r--indoteknik_custom/models/account_move.py16
-rw-r--r--indoteknik_custom/models/commission_internal.py9
-rwxr-xr-xindoteknik_custom/models/purchase_order.py10
-rw-r--r--indoteknik_custom/models/sj_tele.py10
4 files changed, 42 insertions, 3 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 5e38b544..6212664e 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -11,6 +11,7 @@ import re
from terbilang import Terbilang
from collections import defaultdict
from odoo.tools.misc import formatLang
+import socket
_logger = logging.getLogger(__name__)
@@ -218,7 +219,16 @@ class AccountMove(models.Model):
'target': 'new',
}
+ @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)
+
def send_due_invoice_reminder(self):
+ if self.is_local_env():
+ _logger.warning("📪 Local environment detected — skip sending email reminders.")
+ return
today = fields.Date.today()
target_dates = [
today + timedelta(days=7),
@@ -240,6 +250,9 @@ class AccountMove(models.Model):
self._send_invoice_reminders(invoices, mode='due')
def send_overdue_invoice_reminder(self):
+ if self.is_local_env():
+ _logger.warning("📪 Local environment detected — skip sending email reminders.")
+ return
today = fields.Date.today()
invoices = self.env['account.move'].search([
('move_type', '=', 'out_invoice'),
@@ -255,6 +268,9 @@ class AccountMove(models.Model):
self._send_invoice_reminders(invoices, mode='overdue')
def _send_invoice_reminders(self, invoices, mode):
+ if self.is_local_env():
+ _logger.warning("📪 Local environment detected — skip sending email reminders.")
+ return
today = fields.Date.today()
template = self.env.ref('indoteknik_custom.mail_template_invoice_due_reminder')
diff --git a/indoteknik_custom/models/commission_internal.py b/indoteknik_custom/models/commission_internal.py
index 66d32706..cd6da380 100644
--- a/indoteknik_custom/models/commission_internal.py
+++ b/indoteknik_custom/models/commission_internal.py
@@ -194,8 +194,8 @@ class CommissionInternal(models.Model):
list_invoice.append(key)
if key[:5] == 'SO/20':
list_so.append(key)
- invoices = self.env['account.move'].search([('state', '=', 'posted'), ('name', 'in', list_invoice)])
- orders = self.env['sale.order'].search([('state', 'in', ['done', 'sale']), ('name', 'in', list_so)])
+ invoices = self.env['account.move'].search([('name', 'in', list_invoice)])
+ orders = self.env['sale.order'].search([('name', 'in', list_so)])
invoice_data = invoices.mapped(lambda r: {
'res_name': 'account.move',
'res_id': r.id,
@@ -216,6 +216,7 @@ class CommissionInternal(models.Model):
'helper1': line.helper1,
'commission_internal_id': line.commission_internal_id.id,
'commission_internal_line_id': line.id,
+ 'helper2': r.state,
})
sale_data = orders.mapped(lambda r: {
'res_name': 'sale.order',
@@ -237,6 +238,7 @@ class CommissionInternal(models.Model):
'helper1': line.helper1,
'commission_internal_id': line.commission_internal_id.id,
'commission_internal_line_id': line.id,
+ 'helper2': r.state,
})
invoices_and_sales = invoice_data + sale_data
sum_amount_total = sum(item['amount_total'] for item in invoices_and_sales)
@@ -266,7 +268,8 @@ class CommissionInternal(models.Model):
'nomor_uang_masuk': data['nomor_uang_masuk'],
'uang_masuk': data['uang_masuk'],
'linenetamt_prorate': net_amount_prorate,
- 'helper1': data['helper1']
+ 'helper1': data['helper1'],
+ 'helper2': data['helper2']
}])
print(1)
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 4475e777..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:
@@ -121,6 +123,11 @@ class PurchaseOrder(models.Model):
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):
@@ -1140,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:
diff --git a/indoteknik_custom/models/sj_tele.py b/indoteknik_custom/models/sj_tele.py
index 53ba26fc..ed363f59 100644
--- a/indoteknik_custom/models/sj_tele.py
+++ b/indoteknik_custom/models/sj_tele.py
@@ -5,6 +5,7 @@ import json
import logging, subprocess
import time
from collections import OrderedDict
+import socket
_logger = logging.getLogger(__name__)
@@ -20,7 +21,16 @@ class SjTele(models.Model):
date_doc_kirim = fields.Datetime(string='Tanggal Kirim SJ')
is_sent = fields.Boolean(default=False)
+ @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)
+
def woi(self):
+ if self.is_local_env():
+ _logger.warning("📪 Local environment detected — skip sending email reminders.")
+ return
bot_mqdd = '8203414501:AAHy_XwiUAVrgRM2EJzW7sZx9npRLITZpb8'
chat_id_mqdd = '-1003087280519'
api_base = f'https://api.telegram.org/bot{bot_mqdd}'