diff options
| author | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-03-12 17:12:30 +0700 |
|---|---|---|
| committer | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-03-12 17:12:30 +0700 |
| commit | a265a0d89375f54a251969e789410e76deda5e8a (patch) | |
| tree | 1339bc99064ef99bbe688f0c77d4697081bf06ac | |
| parent | 5210640b3b1c790c2e59b24af54587536473f1be (diff) | |
<hafid> fix notif sourcing
| -rw-r--r-- | indoteknik_custom/models/sourcing_job_order.py | 34 | ||||
| -rw-r--r-- | indoteknik_custom/views/sourcing.xml | 10 |
2 files changed, 13 insertions, 31 deletions
diff --git a/indoteknik_custom/models/sourcing_job_order.py b/indoteknik_custom/models/sourcing_job_order.py index 70634e6e..15ea85b0 100644 --- a/indoteknik_custom/models/sourcing_job_order.py +++ b/indoteknik_custom/models/sourcing_job_order.py @@ -648,6 +648,9 @@ class SourcingJobOrderLine(models.Model): def action_ask_approval(self): + if len(self.mapped('order_id')) > 1: + raise UserError("โ Multi Ask Approval hanya boleh untuk line dengan Sourcing Job yang sama.") + bot_sjo = '8335015210:AAGbObP0jQf7ptyqJhYdBYn5Rm0CWOd_yIM' # chat_sjo = self.show_salesperson.partner_id.chat_id_telegram or False chat_sjo = '6076436058' @@ -768,11 +771,6 @@ class SourcingJobOrderLine(models.Model): PurchasePricelist = self.env['purchase.pricelist'] SaleOrderLine = self.env['sale.order.line'] - bot_sjo = '8335015210:AAGbObP0jQf7ptyqJhYdBYn5Rm0CWOd_yIM' - chat_sjo = '-5081839952' - # chat_sjo = '-5147961921' - api_base = f'https://api.telegram.org/bot{bot_sjo}/sendMessage' - for rec in self: job = rec.order_id @@ -908,32 +906,6 @@ class SourcingJobOrderLine(models.Model): title="Approved" ) - base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') - url = f"{base_url}/web#id={job.id}&model=sourcing.job.order&view_type=form" - - try: - msg_text = ( - f"๐ข <b>โ
Sourcing Approved</b>\n\n" - f"๐งพ <b>Sourcing Job:</b> <a href='{url}'>๐ {job.name}</a>\n" - f"๐ฆ <b>Produk:</b> {rec.product_name_md}\n" - f"๐ค <b>Approved By:</b> {rec.show_salesperson.name}\n" - f"๐ค <b>MD:</b> {rec.md_person_ids.name}\n" - f"๐ฐ <b>Harga:</b> {rec.price or 0}\n" - f"๐
<b>Tanggal:</b> {fields.Datetime.now().strftime('%d-%m-%Y %H:%M')}\n\n" - ) - - payload = { - 'chat_id': chat_sjo, - 'text': msg_text, - 'parse_mode': 'HTML' - } - - response = requests.post(api_base, data=payload, timeout=10) - response.raise_for_status() - - except Exception as e: - _logger.warning(f"Gagal kirim telegram approved line: {e}") - so = self.mapped('so_id')[:1] if so: return { diff --git a/indoteknik_custom/views/sourcing.xml b/indoteknik_custom/views/sourcing.xml index cd1de5a4..5a78bbb3 100644 --- a/indoteknik_custom/views/sourcing.xml +++ b/indoteknik_custom/views/sourcing.xml @@ -674,6 +674,16 @@ <field name="groups_id" eval="[(4, ref('indoteknik_custom.group_role_merchandiser'))]"/> </record> + <record id="action_sourcing_job_order_line_multi_ask_approval" model="ir.actions.server"> + <field name="name">Multi Ask Approval</field> + <field name="model_id" ref="model_sourcing_job_order_line"/> + <field name="binding_model_id" ref="model_sourcing_job_order_line"/> + <field name="binding_type">action</field> + <field name="state">code</field> + <field name="code">action = records.action_ask_approval()</field> + <field name="groups_id" eval="[(4, ref('indoteknik_custom.group_role_merchandiser'))]"/> + </record> + <record id="action_sourcing_job_order_md" model="ir.actions.act_window"> <field name="name">Sourcing Job Orders</field> <field name="res_model">sourcing.job.order.line</field> |
