diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-06 08:33:49 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-09-06 08:33:49 +0700 |
| commit | f82137850801cb8d4c8cb482f607b68181ef1cb6 (patch) | |
| tree | 3be0d4616f8d92d9cc170e2f2032a94054b7361e | |
| parent | ba8b646073ee09b962d58b24b340f47d18aa611f (diff) | |
<miqdad> carte
| -rw-r--r-- | indoteknik_custom/models/sj_tele.py | 27 | ||||
| -rw-r--r-- | indoteknik_custom/views/sj_tele.xml | 2 |
2 files changed, 27 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sj_tele.py b/indoteknik_custom/models/sj_tele.py index 246c0f43..c8f7c0c6 100644 --- a/indoteknik_custom/models/sj_tele.py +++ b/indoteknik_custom/models/sj_tele.py @@ -1,7 +1,8 @@ from odoo import models, fields, api +from odoo.exceptions import UserError import requests import json -import logging +import logging, subprocess _logger = logging.getLogger(__name__) @@ -16,6 +17,30 @@ class SjTele(models.Model): sale_name = fields.Char(string='Sale Name') create_date = fields.Datetime(string='Create Date') + @api.model + def run_pentaho_carte(self): + carte = "http://127.0.0.1:8080" + job_kjb = r"C:/Users/ThinkPad/Desktop/tes.kjb" + params = {"job": job_kjb, "level": "Basic", "block": "Y"} + try: + r = requests.get( + f"{carte}/kettle/executeJob/", + params=params, + auth=("cluster", "cluster"), + timeout=900, + ) + r.raise_for_status() + # kalau Carte mengembalikan <result>ERROR</result>, anggap gagal + if "<result>ERROR</result>" in r.text: + raise UserError(f"Carte error: {r.text}") + except Exception as e: + _logger.exception("Carte call failed: %s", e) + raise UserError(f"Gagal memanggil Carte: {e}") + + self.env['sj.tele'].sudo().woi() + + return True + def woi(self): bot_mqdd = '8203414501:AAHy_XwiUAVrgRM2EJzW7sZx9npRLITZpb8' chat_id_mqdd = '-4885333032' diff --git a/indoteknik_custom/views/sj_tele.xml b/indoteknik_custom/views/sj_tele.xml index cefcc968..2e1e5120 100644 --- a/indoteknik_custom/views/sj_tele.xml +++ b/indoteknik_custom/views/sj_tele.xml @@ -4,7 +4,7 @@ <field name="name">SJ TELE</field> <field name="model_id" ref="model_sj_tele"/> <field name="state">code</field> - <field name="code">model.woi()</field> + <field name="code">model.run_pentaho_carte()</field> <field name="interval_number">1</field> <field name="interval_type">days</field> <field name="numbercall">-1</field> |
