diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-01-21 10:19:54 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-01-21 10:19:54 +0700 |
| commit | 696d5e4bf41b927300102293e5027778ffdc9296 (patch) | |
| tree | ce5f4e9f32a0103f91549ffa5904308766799b15 | |
| parent | 1ad2dac26041ba5f445e0299b74ab0ef49c0bcc2 (diff) | |
cr ir actions report
| -rw-r--r-- | indoteknik_custom/models/ir_actions_report.py | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index 94245c1a..28adcf74 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -1,5 +1,6 @@ from odoo import models from odoo.http import request +import requests class IrActionsReport(models.Model): _inherit = 'ir.actions.report' @@ -14,21 +15,37 @@ class IrActionsReport(models.Model): 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', '=', 79160)], 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) + # 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 |
