From 1bf746c93dc5010e30490d0a5ed6a2a174726be0 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 10 Dec 2024 13:21:14 +0700 Subject: update code telegram print so when amount > 200jt --- indoteknik_custom/models/ir_actions_report.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 indoteknik_custom/models/ir_actions_report.py (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py new file mode 100644 index 00000000..d620f8a7 --- /dev/null +++ b/indoteknik_custom/models/ir_actions_report.py @@ -0,0 +1,29 @@ +from odoo import models +import requests +class IrActionsReport(models.Model): + _inherit = 'ir.actions.report' + + def _get_readable_fields(self): + 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 < 200000000: + return + telegram_data = { + 'tittle': sale_order.name, + 'about': 'Permintaan retur ' + sale_order.name, + '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") + for pick in self: + self._check_telegram(pick) + else: + telegram = self.env['website.telegram'].create(telegram_data) + telegram.create_channel() -- cgit v1.2.3 From e81db305d2727e7b95f1bb579315da1597a8185b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 14 Dec 2024 09:47:33 +0700 Subject: update send message to telegram --- indoteknik_custom/models/ir_actions_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index d620f8a7..286c3a3d 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -15,13 +15,13 @@ class IrActionsReport(models.Model): return telegram_data = { 'tittle': sale_order.name, - 'about': 'Permintaan retur ' + sale_order.name, + 'about': sale_order.name + ' Telah Di Print', '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") + 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: -- cgit v1.2.3 From 05d8edef111df1f32be76f3fdfaabfb1c8057644 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 16 Dec 2024 15:05:10 +0700 Subject: update telegram --- indoteknik_custom/models/ir_actions_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index 286c3a3d..f6ef4e3e 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -15,7 +15,7 @@ class IrActionsReport(models.Model): return telegram_data = { 'tittle': sale_order.name, - 'about': sale_order.name + ' Telah Di Print', + 'about': sale_order.name, 'id_data': sale_order.id, 'username': '@' + sale_order.name.replace('/', '') } -- cgit v1.2.3 From 9ba922eded6d752c2a4299c9c444238309877bb9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 20 Dec 2024 09:39:47 +0700 Subject: update code --- indoteknik_custom/models/ir_actions_report.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index f6ef4e3e..b7d4e372 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -16,6 +16,7 @@ class IrActionsReport(models.Model): telegram_data = { 'tittle': sale_order.name, 'about': sale_order.name, + 'user_id': sale_order, 'id_data': sale_order.id, 'username': '@' + sale_order.name.replace('/', '') } -- cgit v1.2.3 From b4a8de6bd7ca7051eee16f877b4e5d8fd65e3056 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 20 Dec 2024 13:57:52 +0700 Subject: add telegram --- indoteknik_custom/models/ir_actions_report.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index b7d4e372..7b1dcee8 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -1,5 +1,5 @@ from odoo import models -import requests +from odoo.http import request class IrActionsReport(models.Model): _inherit = 'ir.actions.report' @@ -13,10 +13,12 @@ class IrActionsReport(models.Model): sale_order = self.env['sale.order'].browse(so_id) if sale_order.amount_total < 200000000: return + # id ci vita 79160 + partner = request.env['res.partner'].search([('id', '=', 112718)], limit=1) telegram_data = { 'tittle': sale_order.name, 'about': sale_order.name, - 'user_id': sale_order, + 'user_id': partner, 'id_data': sale_order.id, 'username': '@' + sale_order.name.replace('/', '') } -- cgit v1.2.3 From 6a7b2e28c9c1612ac3e91ac321b72e3400fdb5a3 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 20 Dec 2024 14:05:19 +0700 Subject: update --- indoteknik_custom/models/ir_actions_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index 7b1dcee8..31bcf168 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -29,4 +29,4 @@ class IrActionsReport(models.Model): self._check_telegram(pick) else: telegram = self.env['website.telegram'].create(telegram_data) - telegram.create_channel() + telegram.create_channel(sale_order.name + " Telah di print Oleh " + self.env.user.name) -- cgit v1.2.3 From 69b84d53a07b77aaca96f88ff4a3b24e52d48fc3 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 20 Jan 2025 12:57:18 +0700 Subject: update code --- indoteknik_custom/models/ir_actions_report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index 31bcf168..e6b9c303 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -14,7 +14,8 @@ class IrActionsReport(models.Model): if sale_order.amount_total < 200000000: return # id ci vita 79160 - partner = request.env['res.partner'].search([('id', '=', 112718)], limit=1) + # id iman 112718 + partner = request.env['res.partner'].search([('id', '=', 79160)], limit=1) telegram_data = { 'tittle': sale_order.name, 'about': sale_order.name, -- cgit v1.2.3 From 717719226f60f6a7c5e89e8db18eb22a62b3391a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 20 Jan 2025 14:35:30 +0700 Subject: push --- indoteknik_custom/models/ir_actions_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index e6b9c303..6e15fbfc 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -4,7 +4,7 @@ class IrActionsReport(models.Model): _inherit = 'ir.actions.report' def _get_readable_fields(self): - self.send_to_telegram() + # self.send_to_telegram() return super()._get_readable_fields() def send_to_telegram(self): -- cgit v1.2.3 From 4b41c2b82a7ec48baf91746dfa9e79b94a17eefb Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 20 Jan 2025 14:45:08 +0700 Subject: hanya send telegram if quotation --- indoteknik_custom/models/ir_actions_report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index 6e15fbfc..c1e84031 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -4,7 +4,8 @@ class IrActionsReport(models.Model): _inherit = 'ir.actions.report' def _get_readable_fields(self): - # self.send_to_telegram() + if self.env.context.get('active_model') == 'sale.order': + self.send_to_telegram() return super()._get_readable_fields() def send_to_telegram(self): -- cgit v1.2.3 From 190e71e69ac16b23f327ff436b1292b9f1aba790 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 21 Jan 2025 08:35:04 +0700 Subject: ganti notif tele 200jt ke 50jt --- indoteknik_custom/models/ir_actions_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index c1e84031..94245c1a 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -12,7 +12,7 @@ class IrActionsReport(models.Model): 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 < 200000000: + if sale_order.amount_total < 50000000: return # id ci vita 79160 # id iman 112718 -- cgit v1.2.3 From 696d5e4bf41b927300102293e5027778ffdc9296 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 21 Jan 2025 10:19:54 +0700 Subject: cr ir actions report --- indoteknik_custom/models/ir_actions_report.py | 49 ++++++++++++++++++--------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') 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 -- cgit v1.2.3 From 64ef15502562e392ddeb011ced08239f9c6934f3 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 24 Jan 2025 09:15:14 +0700 Subject: update code --- indoteknik_custom/models/ir_actions_report.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index 28adcf74..5b49a3ae 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -17,13 +17,13 @@ class IrActionsReport(models.Model): return # ci_vita 7751529082:AAE9XsZa_Pj2Pi2IN1grX98WkwTaIt32pbI & 5081411103 # iman 7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY & 6592318498 - # bot_name_iman = '7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY' - # chat_id_iman = '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' + apiURL = f'https://api.telegram.org/bot{bot_name_iman}/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}) + requests.post(apiURL, json={'chat_id': chat_id_iman, '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) -- cgit v1.2.3 From 1a5b7ce42ffd240da52e01758d636a31c0877e6e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 24 Jan 2025 09:20:45 +0700 Subject: revisi chat id telegram --- indoteknik_custom/models/ir_actions_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/ir_actions_report.py') diff --git a/indoteknik_custom/models/ir_actions_report.py b/indoteknik_custom/models/ir_actions_report.py index 5b49a3ae..83636945 100644 --- a/indoteknik_custom/models/ir_actions_report.py +++ b/indoteknik_custom/models/ir_actions_report.py @@ -18,7 +18,7 @@ class IrActionsReport(models.Model): # ci_vita 7751529082:AAE9XsZa_Pj2Pi2IN1grX98WkwTaIt32pbI & 5081411103 # iman 7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY & 6592318498 bot_name_iman = '7094158106:AAHpWtYOMnA3Yqm_Fvrr3Vw7MrB45vLV9AY' - chat_id_iman = '6592318498' + chat_id_iman = '-1002493002821' bot_name_vita = '7751529082:AAE9XsZa_Pj2Pi2IN1grX98WkwTaIt32pbI' chat_id_vita = '5081411103' apiURL = f'https://api.telegram.org/bot{bot_name_iman}/sendMessage' -- cgit v1.2.3