summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/account_move.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/account_move.py')
-rw-r--r--indoteknik_custom/models/account_move.py16
1 files changed, 16 insertions, 0 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')