summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/ir_actions_report.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-21 13:53:28 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-21 13:53:28 +0700
commit63433ff471ba98e6fc63bca16abd9a585471498b (patch)
tree7fe83758b1c40888bab68f5498e4a1c7da4d7891 /indoteknik_custom/models/ir_actions_report.py
parentff20b62d6932c6be4ffb56f63f3c05be3aa72c06 (diff)
parente3521c2153c36cee6629cee9146e1b4b0201da9f (diff)
Merge branch 'odoo-production' into CR/form-merchant
# Conflicts: # indoteknik_api/models/res_partner.py # indoteknik_api/models/res_users.py # indoteknik_custom/__manifest__.py # indoteknik_custom/models/__init__.py # indoteknik_custom/models/res_partner.py # indoteknik_custom/security/ir.model.access.csv # indoteknik_custom/views/res_partner.xml # indoteknik_custom/views/user_company_request.xml
Diffstat (limited to 'indoteknik_custom/models/ir_actions_report.py')
-rw-r--r--indoteknik_custom/models/ir_actions_report.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py
new file mode 100644
index 00000000..28adcf74
--- /dev/null
+++ b/indoteknik_custom/models/ir_actions_report.py
@@ -0,0 +1,51 @@
+from odoo import models
+from odoo.http import request
+import requests
+class IrActionsReport(models.Model):
+ _inherit = 'ir.actions.report'
+
+ def _get_readable_fields(self):
+ if self.env.context.get('active_model') == 'sale.order':
+ self.send_to_telegram()
+ return super()._get_readable_fields()
+
+ def send_to_telegram(self):
+ so_id = self.env.context.get('active_id')
+ if so_id:
+ sale_order = self.env['sale.order'].browse(so_id)
+ if sale_order.amount_total < 50000000:
+ return
+ # ci_vita 7751529082:AAE9XsZa_Pj2Pi2IN1grX98WkwTaIt32pbI & 5081411103
+ # iman 7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY & 6592318498
+ # bot_name_iman = '7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY'
+ # chat_id_iman = '6592318498'
+ bot_name_vita = '7751529082:AAE9XsZa_Pj2Pi2IN1grX98WkwTaIt32pbI'
+ chat_id_vita = '5081411103'
+ apiURL = f'https://api.telegram.org/bot{bot_name_vita}/sendMessage'
+ try:
+ requests.post(apiURL, json={'chat_id': chat_id_vita, 'text': sale_order.name + " senilai Rp" + self.format_currency(sale_order.amount_total) + ' untuk customer ' + sale_order.partner_id.name + ' telah dibuat oleh sales ' +sale_order.user_id.name})
+ except Exception as e:
+ print(e)
+
+ # id ci vita 79160
+ # id iman 112718
+ # partner = request.env['res.partner'].search([('id', '=', 112718)], limit=1)
+ # telegram_data = {
+ # 'tittle': sale_order.name,
+ # 'about': sale_order.name,
+ # 'user_id': partner,
+ # 'id_data': sale_order.id,
+ # 'username': '@' + sale_order.name.replace('/', '')
+ # }
+ # channel_data = self.env['website.telegram'].search([('tittle', '=', sale_order.name)])
+ # if channel_data:
+ # channel_data.send_to_telegram(sale_order.name + " Telah di print Oleh " + self.env.user.name)
+ # for pick in self:
+ # self._check_telegram(pick)
+ # else:
+ # telegram = self.env['website.telegram'].create(telegram_data)
+ # telegram.create_channel(sale_order.name + " Telah di print Oleh " + self.env.user.name)
+
+ def format_currency(self, number):
+ number = int(number)
+ return "{:,}".format(number).replace(',', '.') \ No newline at end of file