summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/account_move.py
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 /indoteknik_custom/models/account_move.py
parent696a0ef4e25abd39a013503694be11ca2b0645ca (diff)
parent6074d548889ea0bcd489fcc6642eeaec1422cf89 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
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')