summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/ir_actions_report.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2025-01-20 05:58:21 +0000
committerIT Fixcomart <it@fixcomart.co.id>2025-01-20 05:58:21 +0000
commit16abf01b3c6c86212845c0bde2eabd46712ad740 (patch)
treeca8e0c274f53660cec6d64bac8b63e4451f68af0 /indoteknik_custom/models/ir_actions_report.py
parent1b2b27941fcdaa1b1b6ddf2a4851d358abb259eb (diff)
parent69b84d53a07b77aaca96f88ff4a3b24e52d48fc3 (diff)
Merged in iman/telegram (pull request #268)
Iman/telegram
Diffstat (limited to 'indoteknik_custom/models/ir_actions_report.py')
-rw-r--r--indoteknik_custom/models/ir_actions_report.py33
1 files changed, 33 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..e6b9c303
--- /dev/null
+++ b/indoteknik_custom/models/ir_actions_report.py
@@ -0,0 +1,33 @@
+from odoo import models
+from odoo.http import request
+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
+ # 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)