diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-12-10 13:21:14 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-12-10 13:21:14 +0700 |
| commit | 1bf746c93dc5010e30490d0a5ed6a2a174726be0 (patch) | |
| tree | 27be1d61e8d5985e4d202a2723a063445f782348 /indoteknik_custom/models/ir_actions_report.py | |
| parent | bab6a911535b771e988093725e0ba378c77297c6 (diff) | |
<iman> update code telegram print so when amount > 200jt
Diffstat (limited to 'indoteknik_custom/models/ir_actions_report.py')
| -rw-r--r-- | indoteknik_custom/models/ir_actions_report.py | 29 |
1 files changed, 29 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..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() |
