summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-20 12:57:18 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-20 12:57:18 +0700
commit69b84d53a07b77aaca96f88ff4a3b24e52d48fc3 (patch)
treeca8e0c274f53660cec6d64bac8b63e4451f68af0
parentd7a71c347eb3084416cf70c2010665a668491e48 (diff)
<iman> update code
-rw-r--r--indoteknik_custom/models/ir_actions_report.py3
-rw-r--r--indoteknik_custom/models/website_telegram.py14
2 files changed, 11 insertions, 6 deletions
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,
diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py
index 290fd1f9..c655143e 100644
--- a/indoteknik_custom/models/website_telegram.py
+++ b/indoteknik_custom/models/website_telegram.py
@@ -3,6 +3,7 @@ import clipboard
from odoo import models, fields, api
from telethon.sessions import StringSession
from telethon.sync import TelegramClient
+from odoo.exceptions import UserError
from telethon import functions, types
from telethon.tl.types import InputPeerChannel
import asyncio
@@ -52,11 +53,14 @@ class WebsiteTelegram(models.Model):
# Iterasi untuk setiap username
for name in self.user_id:
- user_to_add = await client.get_entity(name.telegram_id)
- result_add_user = await client(functions.channels.InviteToChannelRequest(
- channel=channel,
- users=[user_to_add.id],
- ))
+ if name.telegram_id:
+ user_to_add = await client.get_entity(name.telegram_id)
+ result_add_user = await client(functions.channels.InviteToChannelRequest(
+ channel=channel,
+ users=[user_to_add.id],
+ ))
+ else:
+ raise UserError('ID Telegram '+ name.name + ' salah atau belum diisi')
# message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101'
message_template = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=357&model=sale.order&view_type=form&cids=1&menu_id=212'
message2 = self.tittle + ' di print oleh ' + self.env.user.name