From cc862f2bb8a6a751612bab7fb2d07f7306f9a4fd Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 4 Oct 2024 12:28:29 +0700 Subject: add telegram --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/website_telegram.py | 63 ++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 indoteknik_custom/models/website_telegram.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 3d700ce0..1620c82e 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -128,3 +128,4 @@ from . import sales_order_reject from . import approval_date_doc from . import account_tax from . import approval_unreserve +from . import website_telegram diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py new file mode 100644 index 00000000..8fc6a8ea --- /dev/null +++ b/indoteknik_custom/models/website_telegram.py @@ -0,0 +1,63 @@ +import requests + +import clipboard + +from odoo import models, fields, api + +class WebsiteTelegram(models.Model): + _name = 'website.telegram' + _description = 'Telegram Channel' + + name = fields.Char(string='Bot Name', required=True) + bot_name = fields.Char(string='Bot Token', help="Create your bot from Bot Father form Telegram App", required=True, ) + python_code = fields.Char(compute="_calc_python_code") + chatID = fields.Char(string='Channel Name', required=True, help="Create yor channel , Add members , Add Bot As an Admin") + + test_message = fields.Char(string='Test Message', required=False, default='Test') + + def send_to_telegram(self, message): + # if self.env.all.registry.db_name == 'odoo016':return + + # message = self.env.all.registry.db_name + " : " + message + message = self.test_message + + apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage' + try: + requests.post(apiURL, json={'chat_id': self.chatID, 'text': message}) + except Exception as e: + print(e) + + def test_send(self): + try: + self.env.cr.savepoint() + + self.env['website.telegram'].search([('name', '=', self.name)])[0].send_to_telegram(self.test_message) + except Exception as e: + print(e) + + @api.depends('name', 'chatID', 'bot_name') + def _calc_python_code(self): + for record in self: + if not record.name: + record.python_code = "pleas put a name" + elif not record.test_message: + record.test_message = "test" + else: + record.python_code = "self.env['website.telegram'].search([('name', '=', '" + record.name + "')])[0].send_to_telegram('" + record.test_message + "')" + + def copy_chat_id(self): + record = self.browse(self.id) + clipboard.copy(record.python_code) + + def paste_chat_id(self): + record = self.browse(self.id) + chat_id = clipboard.paste() + record.write({'chatID': chat_id}) + + def paste_bot_name(self): + record = self.browse(self.id) + bot_name = clipboard.paste() + record.write({'bot_name': bot_name}) + + + -- cgit v1.2.3 From ec1e2331be248a505d89c00244d6b0fe5bd61c26 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 4 Oct 2024 14:31:33 +0700 Subject: add get text from channel --- indoteknik_custom/models/website_telegram.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 8fc6a8ea..bb3031a0 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -29,7 +29,7 @@ class WebsiteTelegram(models.Model): def test_send(self): try: - self.env.cr.savepoint() + self.env.cr.savepoint() #kembalikan database ke save point jika mengalami kesalahan self.env['website.telegram'].search([('name', '=', self.name)])[0].send_to_telegram(self.test_message) except Exception as e: @@ -59,5 +59,24 @@ class WebsiteTelegram(models.Model): bot_name = clipboard.paste() record.write({'bot_name': bot_name}) + def get_updates(self): + apiURL = f'https://api.telegram.org/bot{self.bot_name}/getUpdates' + try: + response = requests.get(apiURL) + updates = response.json() + return updates # Ini akan berisi semua pembaruan, termasuk pesan baru + except Exception as e: + print(e) + return None + + def receive_messages(self): + updates = self.get_updates() + if updates and 'result' in updates: + for update in updates['result']: + if 'text' in update['channel_post']: + message_text = update['channel_post']['text'] + chat_id = update['channel_post']['chat']['id'] + chat_name = update['channel_post']['chat']['username'] + print(f"Received message: {message_text} from chat_id: {chat_id}, that is: {chat_name}") -- cgit v1.2.3 From 04d994e53a36ea9a6f7a2c0dd3f5f1b2c0ca9a74 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 8 Oct 2024 15:37:58 +0700 Subject: update code --- indoteknik_custom/models/website_telegram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index bb3031a0..5684eff8 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -19,7 +19,7 @@ class WebsiteTelegram(models.Model): # if self.env.all.registry.db_name == 'odoo016':return # message = self.env.all.registry.db_name + " : " + message - message = self.test_message + # message = self.test_message apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage' try: -- cgit v1.2.3 From 94141d0871e9abed968d3c249eeaf7b3c1ae87d9 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 9 Oct 2024 15:59:34 +0700 Subject: update telegram create channel --- indoteknik_custom/models/stock_picking.py | 7 +++++ indoteknik_custom/models/website_telegram.py | 39 +++++++++++++++++++++------- 2 files changed, 37 insertions(+), 9 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 14190474..5397b59f 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -4,6 +4,7 @@ from odoo.tools.float_utils import float_is_zero from datetime import datetime from itertools import groupby import pytz, datetime +from odoo.http import request class StockPicking(models.Model): @@ -310,11 +311,17 @@ class StockPicking(models.Model): self.approval_receipt_status = 'pengajuan1' def ask_return_approval(self): + telegram_data = { + 'tittle': 'Permintaan retur ' + self.name, + 'about': 'Permintaan retur ' + self.name, + } + telegram = request.env['website.telegram'].create(telegram_data) for pick in self: if self.env.user.is_accounting: pick.approval_return_status = 'approved' else: pick.approval_return_status = 'pengajuan1' + telegram.create_channel() def calculate_line_no(self): for picking in self: diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 5684eff8..c0e7be2f 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -1,19 +1,40 @@ import requests - import clipboard - from odoo import models, fields, api +from telethon.sessions import StringSession +from telethon.sync import TelegramClient +from telethon import functions, types +from telethon.tl.types import InputChannel, InputPeerChannel +import asyncio class WebsiteTelegram(models.Model): _name = 'website.telegram' _description = 'Telegram Channel' - - name = fields.Char(string='Bot Name', required=True) - bot_name = fields.Char(string='Bot Token', help="Create your bot from Bot Father form Telegram App", required=True, ) - python_code = fields.Char(compute="_calc_python_code") - chatID = fields.Char(string='Channel Name', required=True, help="Create yor channel , Add members , Add Bot As an Admin") - - test_message = fields.Char(string='Test Message', required=False, default='Test') + tittle = fields.Char("Channel Title") + about = fields.Char("Channel Description") + is_broadcast = fields.Boolean("Is Broadcast", default=True) + is_megagroup = fields.Boolean("Is Megagroup", default=False) + # session_string = 'MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIRyy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwvplUUI1PLTktZ9uW2WE23b+ixNwJjJGwBDJPQEQFBE+vfmH0JP503wr5INS1poWg/j25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCOj4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB' + + def create_channel(self, *args, **kwargs): + asyncio.run(self._async_create_channel()) + + async def _async_create_channel(self): + async with TelegramClient(StringSession('1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), 27799517, 'df8ee44b0ed11108245037d47b511201') as client: + result = await client(functions.channels.CreateChannelRequest( + title=self.tittle, + about=self.about, + broadcast=True, + megagroup=False, + )) + channel = result.updates[3].message.peer_id + username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] + for name in username_to_add: + user_to_add = await client.get_entity(name) + result = await client(functions.channels.InviteToChannelRequest( + channel=channel, + users=[user_to_add.id], + )) def send_to_telegram(self, message): # if self.env.all.registry.db_name == 'odoo016':return -- cgit v1.2.3 From dcbb5680c9dd6ecf18eaf3dbbc3af26ac7a47134 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 9 Oct 2024 17:00:18 +0700 Subject: update bisa kirim chat --- indoteknik_custom/models/stock_picking.py | 1 + indoteknik_custom/models/website_telegram.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 5397b59f..b65d06e4 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -314,6 +314,7 @@ class StockPicking(models.Model): telegram_data = { 'tittle': 'Permintaan retur ' + self.name, 'about': 'Permintaan retur ' + self.name, + 'id_data': self.id } telegram = request.env['website.telegram'].create(telegram_data) for pick in self: diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index c0e7be2f..45927b73 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -6,11 +6,13 @@ from telethon.sync import TelegramClient from telethon import functions, types from telethon.tl.types import InputChannel, InputPeerChannel import asyncio +from telethon.tl.functions.messages import SendMessageRequest class WebsiteTelegram(models.Model): _name = 'website.telegram' _description = 'Telegram Channel' tittle = fields.Char("Channel Title") + id_data = fields.Char("Channel ID") about = fields.Char("Channel Description") is_broadcast = fields.Boolean("Is Broadcast", default=True) is_megagroup = fields.Boolean("Is Megagroup", default=False) @@ -24,8 +26,8 @@ class WebsiteTelegram(models.Model): result = await client(functions.channels.CreateChannelRequest( title=self.tittle, about=self.about, - broadcast=True, - megagroup=False, + broadcast=False, + megagroup=True, )) channel = result.updates[3].message.peer_id username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] @@ -35,6 +37,8 @@ class WebsiteTelegram(models.Model): channel=channel, users=[user_to_add.id], )) + message = 'https://erp.indoteknik.com/web#id='+self.id_data+'&action=209&model=stock.picking&view_type=form&cids=1&menu_id=101' + result = await client(SendMessageRequest(channel, message)) def send_to_telegram(self, message): # if self.env.all.registry.db_name == 'odoo016':return -- cgit v1.2.3 From 9c6e2e8f35f14dda376e543e5b63b0bddee2fd88 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 10 Oct 2024 08:53:39 +0700 Subject: update telegram --- indoteknik_custom/models/stock_picking.py | 3 +- indoteknik_custom/models/website_telegram.py | 41 +++++++++++++++++++++------- 2 files changed, 33 insertions(+), 11 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index b65d06e4..58eb5d82 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -314,7 +314,8 @@ class StockPicking(models.Model): telegram_data = { 'tittle': 'Permintaan retur ' + self.name, 'about': 'Permintaan retur ' + self.name, - 'id_data': self.id + 'id_data': self.id, + 'username': '@'+self.name.replace('/', '') } telegram = request.env['website.telegram'].create(telegram_data) for pick in self: diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 45927b73..d67cafc5 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -12,6 +12,7 @@ class WebsiteTelegram(models.Model): _name = 'website.telegram' _description = 'Telegram Channel' tittle = fields.Char("Channel Title") + username = fields.Char("Channel Name") id_data = fields.Char("Channel ID") about = fields.Char("Channel Description") is_broadcast = fields.Boolean("Is Broadcast", default=True) @@ -30,7 +31,8 @@ class WebsiteTelegram(models.Model): megagroup=True, )) channel = result.updates[3].message.peer_id - username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] + # username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] + username_to_add = ['@imsep81'] for name in username_to_add: user_to_add = await client.get_entity(name) result = await client(functions.channels.InviteToChannelRequest( @@ -40,6 +42,24 @@ class WebsiteTelegram(models.Model): message = 'https://erp.indoteknik.com/web#id='+self.id_data+'&action=209&model=stock.picking&view_type=form&cids=1&menu_id=101' result = await client(SendMessageRequest(channel, message)) + result = client(functions.channels.UpdateUsernameRequest( + channel=channel, + username='@indoJaya21' + )) + print(result.stringify()) + + def receive_messages(self): + asyncio.run(self._async_receive_messages()) + + async def _async_receive_messages(self): + async with TelegramClient(StringSession('1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), + 27799517, 'df8ee44b0ed11108245037d47b511201') as client: + channel = await client.get_entity(self.username) + result = client(functions.channels.GetMessagesRequest( + channel=channel, + id=channel.chats + )) + print(result.stringify()) def send_to_telegram(self, message): # if self.env.all.registry.db_name == 'odoo016':return @@ -94,14 +114,15 @@ class WebsiteTelegram(models.Model): print(e) return None - def receive_messages(self): - updates = self.get_updates() - if updates and 'result' in updates: - for update in updates['result']: - if 'text' in update['channel_post']: - message_text = update['channel_post']['text'] - chat_id = update['channel_post']['chat']['id'] - chat_name = update['channel_post']['chat']['username'] - print(f"Received message: {message_text} from chat_id: {chat_id}, that is: {chat_name}") + # def receive_messages(self): + # updates = self.get_updates() + # if updates and 'result' in updates: + # for update in updates['result']: + # if 'text' in update['channel_post']: + # message_text = update['channel_post']['text'] + # chat_id = update['channel_post']['chat']['id'] + # chat_name = update['channel_post']['chat']['username'] + # print(f"Received message: {message_text} from chat_id: {chat_id}, that is: {chat_name}") + -- cgit v1.2.3 From c631620706a24426faea6b43c2a0602eebf9a5e4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 11 Oct 2024 10:02:33 +0700 Subject: fix code get telegram api --- indoteknik_custom/models/stock_picking.py | 37 ++++++++--- indoteknik_custom/models/website_telegram.py | 92 +++++++++++++++++++--------- 2 files changed, 91 insertions(+), 38 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 58eb5d82..5f2fe99a 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -312,18 +312,39 @@ class StockPicking(models.Model): def ask_return_approval(self): telegram_data = { - 'tittle': 'Permintaan retur ' + self.name, + 'tittle': self.name, 'about': 'Permintaan retur ' + self.name, 'id_data': self.id, 'username': '@'+self.name.replace('/', '') } - telegram = request.env['website.telegram'].create(telegram_data) - for pick in self: - if self.env.user.is_accounting: - pick.approval_return_status = 'approved' - else: - pick.approval_return_status = 'pengajuan1' - telegram.create_channel() + channel_data = self.env['website.telegram'].search([('tittle', '=', self.name)]) + if channel_data: + for pick in self: + self._check_telegram(pick) + else: + telegram = request.env['website.telegram'].create(telegram_data) + telegram.create_channel() + for pick in self: + pick.approval_return_status = 'pengajuan1' + + def read(self, fields=None, load='_classic_read'): + # Panggil method 'read' bawaan terlebih dahulu + records = super(StockPicking, self).read(fields, load) + + # Jalankan _check_telegram untuk setiap record yang diakses + for record in self: + if record.approval_return_status == 'pengajuan1': + record._check_telegram() + + return records + + + def _check_telegram(self): + telegram = self.env['website.telegram'].search([('id_data', '=', self.id)]) + if telegram: + ask_return = telegram.receive_messages() + if ask_return: + self.approval_return_status = 'approved' def calculate_line_no(self): for picking in self: diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index d67cafc5..8bd789a1 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -4,68 +4,103 @@ from odoo import models, fields, api from telethon.sessions import StringSession from telethon.sync import TelegramClient from telethon import functions, types -from telethon.tl.types import InputChannel, InputPeerChannel +from telethon.tl.types import InputPeerChannel import asyncio from telethon.tl.functions.messages import SendMessageRequest +from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, PeerChannel +import datetime +from telethon.tl.types import MessageMediaPoll +from telethon.tl.functions.messages import SendMediaRequest +from telethon.tl.types import TextWithEntities class WebsiteTelegram(models.Model): _name = 'website.telegram' _description = 'Telegram Channel' tittle = fields.Char("Channel Title") + invite_link = fields.Char("Channel invite link") username = fields.Char("Channel Name") id_data = fields.Char("Channel ID") about = fields.Char("Channel Description") is_broadcast = fields.Boolean("Is Broadcast", default=True) is_megagroup = fields.Boolean("Is Megagroup", default=False) + is_accept = fields.Boolean("Is Megagroup", default=False) + # session_string = 'MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIRyy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwvplUUI1PLTktZ9uW2WE23b+ixNwJjJGwBDJPQEQFBE+vfmH0JP503wr5INS1poWg/j25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCOj4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB' def create_channel(self, *args, **kwargs): asyncio.run(self._async_create_channel()) async def _async_create_channel(self): - async with TelegramClient(StringSession('1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), 27799517, 'df8ee44b0ed11108245037d47b511201') as client: + async with TelegramClient(StringSession( + '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), + 27799517, 'df8ee44b0ed11108245037d47b511201') as client: result = await client(functions.channels.CreateChannelRequest( - title=self.tittle, + title='Permintaan retur ' + self.tittle, about=self.about, broadcast=False, megagroup=True, )) channel = result.updates[3].message.peer_id - # username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] - username_to_add = ['@imsep81'] + channel_link = await client(functions.messages.ExportChatInviteRequest( + peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash), + )) + self.invite_link = channel_link.link + username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] + # username_to_add = ['@imsep81'] for name in username_to_add: user_to_add = await client.get_entity(name) - result = await client(functions.channels.InviteToChannelRequest( + result_add_user = await client(functions.channels.InviteToChannelRequest( channel=channel, users=[user_to_add.id], )) - message = 'https://erp.indoteknik.com/web#id='+self.id_data+'&action=209&model=stock.picking&view_type=form&cids=1&menu_id=101' - result = await client(SendMessageRequest(channel, message)) - - result = client(functions.channels.UpdateUsernameRequest( - channel=channel, - username='@indoJaya21' + message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=stock.picking&view_type=form&cids=1&menu_id=101' + result_massage = await client(SendMessageRequest(channel, message)) + + # Send the poll to the channel using PeerChannel with the channel's ID + result_polling = await client(SendMediaRequest( + peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash), + media=InputMediaPoll(poll=Poll( + question=TextWithEntities(text="ASK RETURN?", entities=[]), + answers=[ + PollAnswer(text=TextWithEntities(text="Accept", entities=[]), option=b'\x01'), + PollAnswer(text=TextWithEntities(text="Reject", entities=[]), option=b'\x02'), + ], + id=2 + )), + message='Ask Return Polling' )) - print(result.stringify()) def receive_messages(self): - asyncio.run(self._async_receive_messages()) + return asyncio.run(self._async_receive_messages()) async def _async_receive_messages(self): - async with TelegramClient(StringSession('1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), - 27799517, 'df8ee44b0ed11108245037d47b511201') as client: - channel = await client.get_entity(self.username) - result = client(functions.channels.GetMessagesRequest( - channel=channel, - id=channel.chats + async with TelegramClient(StringSession( + '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), + 27799517, 'df8ee44b0ed11108245037d47b511201') as client: + channel = await client.get_entity(self.invite_link) + result = await client(functions.messages.GetHistoryRequest( + peer=channel, + offset_id=42, + offset_date=datetime.datetime(2024, 12, 31), + add_offset=0, + limit=100, + max_id=0, + min_id=0, + hash=channel.access_hash )) - print(result.stringify()) - def send_to_telegram(self, message): - # if self.env.all.registry.db_name == 'odoo016':return + accept_found = False + + for message in result.messages: + if not isinstance(message.media, MessageMediaPoll): + continue + if message.media.results.total_voters > 0: + if message.media.results.results[0].voters > message.media.results.results[1].voters: + accept_found = True + break - # message = self.env.all.registry.db_name + " : " + message - # message = self.test_message + return accept_found + def send_to_telegram(self, message): apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage' try: requests.post(apiURL, json={'chat_id': self.chatID, 'text': message}) @@ -74,7 +109,7 @@ class WebsiteTelegram(models.Model): def test_send(self): try: - self.env.cr.savepoint() #kembalikan database ke save point jika mengalami kesalahan + self.env.cr.savepoint() self.env['website.telegram'].search([('name', '=', self.name)])[0].send_to_telegram(self.test_message) except Exception as e: @@ -109,7 +144,7 @@ class WebsiteTelegram(models.Model): try: response = requests.get(apiURL) updates = response.json() - return updates # Ini akan berisi semua pembaruan, termasuk pesan baru + return updates except Exception as e: print(e) return None @@ -123,6 +158,3 @@ class WebsiteTelegram(models.Model): # chat_id = update['channel_post']['chat']['id'] # chat_name = update['channel_post']['chat']['username'] # print(f"Received message: {message_text} from chat_id: {chat_id}, that is: {chat_name}") - - - -- cgit v1.2.3 From 6ad0aa164ed76c8889fd76bff99f5d57b1ac1b2e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 4 Dec 2024 15:31:54 +0700 Subject: add telegram --- indoteknik_custom/models/sale_order.py | 14 ++++++++++++++ indoteknik_custom/models/website_telegram.py | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 7fc6d96a..88bbe3cf 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -145,6 +145,20 @@ class SaleOrder(models.Model): ('NP', 'Non Pareto') ]) + def action_print_proforma_invoice(self): + """Cetak laporan Jasper secara langsung""" + self.ensure_one() + # Konfigurasi laporan Jasper + report_action = self.env['ir.actions.report'].search([ + ('model', '=', 'sale.order'), + ('report_name', '=', 'Proforma Invoice New') + ], limit=1) + + if report_action: + return report_action.report_action(self) + else: + raise ValueError('Report not found!') + @api.onchange('payment_status') def _is_continue_transaction(self): if not self.is_continue_transaction: diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 8bd789a1..e17da371 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -45,8 +45,8 @@ class WebsiteTelegram(models.Model): peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash), )) self.invite_link = channel_link.link - username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] - # username_to_add = ['@imsep81'] + # username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] + username_to_add = ['@imsep81'] for name in username_to_add: user_to_add = await client.get_entity(name) result_add_user = await client(functions.channels.InviteToChannelRequest( -- cgit v1.2.3 From bab6a911535b771e988093725e0ba378c77297c6 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 10 Dec 2024 08:58:25 +0700 Subject: update telegram --- indoteknik_custom/models/sale_order.py | 14 -------------- indoteknik_custom/models/website_telegram.py | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 88bbe3cf..7fc6d96a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -145,20 +145,6 @@ class SaleOrder(models.Model): ('NP', 'Non Pareto') ]) - def action_print_proforma_invoice(self): - """Cetak laporan Jasper secara langsung""" - self.ensure_one() - # Konfigurasi laporan Jasper - report_action = self.env['ir.actions.report'].search([ - ('model', '=', 'sale.order'), - ('report_name', '=', 'Proforma Invoice New') - ], limit=1) - - if report_action: - return report_action.report_action(self) - else: - raise ValueError('Report not found!') - @api.onchange('payment_status') def _is_continue_transaction(self): if not self.is_continue_transaction: diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index e17da371..58816fe2 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -46,7 +46,7 @@ class WebsiteTelegram(models.Model): )) self.invite_link = channel_link.link # username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] - username_to_add = ['@imsep81'] + username_to_add = ['@radiant81'] for name in username_to_add: user_to_add = await client.get_entity(name) result_add_user = await client(functions.channels.InviteToChannelRequest( -- cgit v1.2.3 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/__init__.py | 1 + indoteknik_custom/models/ir_actions_report.py | 29 ++++++++++++++++++ indoteknik_custom/models/stock_picking.py | 34 --------------------- indoteknik_custom/models/website_telegram.py | 43 ++++++++++++++++----------- 4 files changed, 55 insertions(+), 52 deletions(-) create mode 100644 indoteknik_custom/models/ir_actions_report.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 1e0cedc9..b319883c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -135,3 +135,4 @@ from . import find_page from . import approval_retur_picking from . import va_multi_approve from . import va_multi_reject +from . import ir_actions_report 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() diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 2095e957..31c45531 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -468,40 +468,6 @@ class StockPicking(models.Model): raise UserError('Harus Sales Admin yang Ask Return') else: raise UserError('Harus Purchasing yang Ask Return') - telegram_data = { - 'tittle': self.name, - 'about': 'Permintaan retur ' + self.name, - 'id_data': self.id, - 'username': '@'+self.name.replace('/', '') - } - channel_data = self.env['website.telegram'].search([('tittle', '=', self.name)]) - if channel_data: - for pick in self: - self._check_telegram(pick) - else: - telegram = request.env['website.telegram'].create(telegram_data) - telegram.create_channel() - for pick in self: - pick.approval_return_status = 'pengajuan1' - - def read(self, fields=None, load='_classic_read'): - # Panggil method 'read' bawaan terlebih dahulu - records = super(StockPicking, self).read(fields, load) - - # Jalankan _check_telegram untuk setiap record yang diakses - for record in self: - if record.approval_return_status == 'pengajuan1': - record._check_telegram() - - return records - - - def _check_telegram(self): - telegram = self.env['website.telegram'].search([('id_data', '=', self.id)]) - if telegram: - ask_return = telegram.receive_messages() - if ask_return: - self.approval_return_status = 'approved' def calculate_line_no(self): diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 58816fe2..92707ea2 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -35,7 +35,7 @@ class WebsiteTelegram(models.Model): '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), 27799517, 'df8ee44b0ed11108245037d47b511201') as client: result = await client(functions.channels.CreateChannelRequest( - title='Permintaan retur ' + self.tittle, + title=self.tittle + ' Telah Diprint', about=self.about, broadcast=False, megagroup=True, @@ -45,30 +45,30 @@ class WebsiteTelegram(models.Model): peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash), )) self.invite_link = channel_link.link - # username_to_add = ['@imsep81', '6285764475716', '@stephanchrst'] - username_to_add = ['@radiant81'] + # username_to_add = ['@radiant81', '6285764475716', '@stephanchrst'] + username_to_add = ['6282339129611'] for name in username_to_add: user_to_add = await client.get_entity(name) result_add_user = await client(functions.channels.InviteToChannelRequest( channel=channel, users=[user_to_add.id], )) - message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=stock.picking&view_type=form&cids=1&menu_id=101' + message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101' result_massage = await client(SendMessageRequest(channel, message)) # Send the poll to the channel using PeerChannel with the channel's ID - result_polling = await client(SendMediaRequest( - peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash), - media=InputMediaPoll(poll=Poll( - question=TextWithEntities(text="ASK RETURN?", entities=[]), - answers=[ - PollAnswer(text=TextWithEntities(text="Accept", entities=[]), option=b'\x01'), - PollAnswer(text=TextWithEntities(text="Reject", entities=[]), option=b'\x02'), - ], - id=2 - )), - message='Ask Return Polling' - )) + # result_polling = await client(SendMediaRequest( + # peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash), + # media=InputMediaPoll(poll=Poll( + # question=TextWithEntities(text="ASK RETURN?", entities=[]), + # answers=[ + # PollAnswer(text=TextWithEntities(text="Accept", entities=[]), option=b'\x01'), + # PollAnswer(text=TextWithEntities(text="Reject", entities=[]), option=b'\x02'), + # ], + # id=2 + # )), + # message='Ask Return Polling' + # )) def receive_messages(self): return asyncio.run(self._async_receive_messages()) @@ -101,12 +101,19 @@ class WebsiteTelegram(models.Model): return accept_found def send_to_telegram(self, message): - apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage' + # apiURL = f'https://api.telegram.org/bot{self.bot_name}/sendMessage' try: - requests.post(apiURL, json={'chat_id': self.chatID, 'text': message}) + # requests.post(apiURL, json={'chat_id': self.chatID, 'text': message}) + asyncio.run(self._async_send_to_telegram(message)) except Exception as e: print(e) + async def _async_send_to_telegram(self, message): + async with TelegramClient(StringSession( + '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), + 27799517, 'df8ee44b0ed11108245037d47b511201') as client: + channel = await client.get_entity(self.invite_link) + result_massage = await client(SendMessageRequest(channel, message)) def test_send(self): try: self.env.cr.savepoint() -- 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 ++-- indoteknik_custom/models/website_telegram.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') 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: diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 92707ea2..25dea14e 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -54,7 +54,9 @@ class WebsiteTelegram(models.Model): users=[user_to_add.id], )) message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101' + message2 = self.tittle + ' di print oleh ' + self.env.user.name result_massage = await client(SendMessageRequest(channel, message)) + result_massage2 = await client(SendMessageRequest(channel, message2)) # Send the poll to the channel using PeerChannel with the channel's ID # result_polling = await client(SendMediaRequest( -- 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 +- indoteknik_custom/models/website_telegram.py | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models') 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('/', '') } diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 25dea14e..a3c64c7e 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -16,9 +16,13 @@ from telethon.tl.types import TextWithEntities class WebsiteTelegram(models.Model): _name = 'website.telegram' _description = 'Telegram Channel' + + tittle = fields.Char("Channel Title") invite_link = fields.Char("Channel invite link") username = fields.Char("Channel Name") + username_to_add = fields.Char("username to add on channel", compute='_compute_username_to_add') + user_id = fields.Many2many('res.partner', string='User Member', store=True) id_data = fields.Char("Channel ID") about = fields.Char("Channel Description") is_broadcast = fields.Boolean("Is Broadcast", default=True) @@ -27,6 +31,11 @@ class WebsiteTelegram(models.Model): # session_string = 'MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIRyy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwvplUUI1PLTktZ9uW2WE23b+ixNwJjJGwBDJPQEQFBE+vfmH0JP503wr5INS1poWg/j25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCOj4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB' + @api.depends('user_id') + def _compute_username_to_add(self): + for name in self.user_id: + self.username_to_add.append(str(name.mobile)) + def create_channel(self, *args, **kwargs): asyncio.run(self._async_create_channel()) @@ -35,7 +44,7 @@ class WebsiteTelegram(models.Model): '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), 27799517, 'df8ee44b0ed11108245037d47b511201') as client: result = await client(functions.channels.CreateChannelRequest( - title=self.tittle + ' Telah Diprint', + title=self.tittle, about=self.about, broadcast=False, megagroup=True, @@ -115,12 +124,21 @@ class WebsiteTelegram(models.Model): '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), 27799517, 'df8ee44b0ed11108245037d47b511201') as client: channel = await client.get_entity(self.invite_link) + + for name in self.username_to_add: + data = name + user_to_add = await client.get_entity(data) + result_add_user = await client(functions.channels.InviteToChannelRequest( + channel=channel, + users=[user_to_add.id], + )) result_massage = await client(SendMessageRequest(channel, message)) + def test_send(self): try: self.env.cr.savepoint() - self.env['website.telegram'].search([('name', '=', self.name)])[0].send_to_telegram(self.test_message) + self.env['website.telegram'].search([('tittle', '=', self.tittle)])[0].send_to_telegram('test message') except Exception as e: print(e) -- 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 + indoteknik_custom/models/website_telegram.py | 38 ++++++++++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'indoteknik_custom/models') 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('/', '') } diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index a3c64c7e..ade6c326 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -33,8 +33,13 @@ class WebsiteTelegram(models.Model): @api.depends('user_id') def _compute_username_to_add(self): - for name in self.user_id: - self.username_to_add.append(str(name.mobile)) + for record in self: + usernames = [] + for partner in record.user_id: + if partner.mobile: # Pastikan mobile tidak None + usernames.append(partner.mobile) + # Gabungkan semua nomor menjadi satu string, dipisahkan koma + record.username_to_add = ', '.join(usernames) def create_channel(self, *args, **kwargs): asyncio.run(self._async_create_channel()) @@ -125,14 +130,27 @@ class WebsiteTelegram(models.Model): 27799517, 'df8ee44b0ed11108245037d47b511201') as client: channel = await client.get_entity(self.invite_link) - for name in self.username_to_add: - data = name - user_to_add = await client.get_entity(data) - result_add_user = await client(functions.channels.InviteToChannelRequest( - channel=channel, - users=[user_to_add.id], - )) - result_massage = await client(SendMessageRequest(channel, message)) + # Memproses username_to_add menjadi list + usernames = self.username_to_add.split(', ') # Pisahkan berdasarkan koma dan spasi + + # Iterasi untuk setiap username + for username in usernames: + if username: # Pastikan username tidak kosong + try: + # Mendapatkan entitas user berdasarkan username + user_to_add = await client.get_entity(username) + + # Mengundang user ke channel + result_add_user = await client(functions.channels.InviteToChannelRequest( + channel=channel, + users=[user_to_add.id], + )) + except Exception as e: + # Tangani error (misal user tidak ditemukan atau sudah ada di channel) + print(f"Error adding user {username}: {e}") + + # Mengirim pesan ke channel + result_message = await client(SendMessageRequest(channel, message)) def test_send(self): try: -- 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 ++++-- indoteknik_custom/models/res_partner.py | 1 + indoteknik_custom/models/website_telegram.py | 26 ++++++++++---------------- 3 files changed, 15 insertions(+), 18 deletions(-) (limited to 'indoteknik_custom/models') 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('/', '') } diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index da4a6cb6..c648c729 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -74,6 +74,7 @@ class ResPartner(models.Model): "customer is crossed blocking amount." "Set its value to 0.00 to disable " "this feature", tracking=3) + telegram_id = fields.Char(string="Telegram") @api.model def _default_payment_term(self): diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index ade6c326..7d76f27d 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -36,7 +36,7 @@ class WebsiteTelegram(models.Model): for record in self: usernames = [] for partner in record.user_id: - if partner.mobile: # Pastikan mobile tidak None + if partner.telegram_id: # Pastikan mobile tidak None usernames.append(partner.mobile) # Gabungkan semua nomor menjadi satu string, dipisahkan koma record.username_to_add = ', '.join(usernames) @@ -59,15 +59,16 @@ class WebsiteTelegram(models.Model): peer=InputPeerChannel(channel_id=channel.channel_id, access_hash=result.chats[0].access_hash), )) self.invite_link = channel_link.link - # username_to_add = ['@radiant81', '6285764475716', '@stephanchrst'] - username_to_add = ['6282339129611'] - for name in username_to_add: - user_to_add = await client.get_entity(name) + + # 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], )) - message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101' + # message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101' + message = '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 result_massage = await client(SendMessageRequest(channel, message)) result_massage2 = await client(SendMessageRequest(channel, message2)) @@ -130,26 +131,19 @@ class WebsiteTelegram(models.Model): 27799517, 'df8ee44b0ed11108245037d47b511201') as client: channel = await client.get_entity(self.invite_link) - # Memproses username_to_add menjadi list - usernames = self.username_to_add.split(', ') # Pisahkan berdasarkan koma dan spasi - # Iterasi untuk setiap username - for username in usernames: - if username: # Pastikan username tidak kosong + for username in self.user_id: + if username: try: - # Mendapatkan entitas user berdasarkan username - user_to_add = await client.get_entity(username) + user_to_add = await client.get_entity(username.telegram_id) - # Mengundang user ke channel result_add_user = await client(functions.channels.InviteToChannelRequest( channel=channel, users=[user_to_add.id], )) except Exception as e: - # Tangani error (misal user tidak ditemukan atau sudah ada di channel) print(f"Error adding user {username}: {e}") - # Mengirim pesan ke channel result_message = await client(SendMessageRequest(channel, message)) def test_send(self): -- 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 +- indoteknik_custom/models/website_telegram.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'indoteknik_custom/models') 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) diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 7d76f27d..74955b7b 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -41,10 +41,10 @@ class WebsiteTelegram(models.Model): # Gabungkan semua nomor menjadi satu string, dipisahkan koma record.username_to_add = ', '.join(usernames) - def create_channel(self, *args, **kwargs): - asyncio.run(self._async_create_channel()) + def create_channel(self, message): + asyncio.run(self._async_create_channel(message)) - async def _async_create_channel(self): + async def _async_create_channel(self, message): async with TelegramClient(StringSession( '1BVtsOJABu30MWCBFwYvvaYbFoIWi43r5a7TUZ2IWwrnSlXIwEhJS5k2y4UKjoDeMPKwhgUWn9lMk02zQjM0ZDzq61YyhkRBvZuu3hCxMsrtP92bkuZtL2g3g1VgI8s7rMhOD_WaGrZbuj-TmbTwIEbN5i1J4raDW2kYzmlLRCbT74xxrGjpzWCnVv7CSS9L2juXuut0lLMgli3_JZbqDO1IyBYh4ZFQYbMf7zv6moDR4MQp1qfnFArsikQcfxjlNXKFcSoyA_GjiIFfCuymwQVtdERXOAH03M_lm8fYbjvgxEkJvxR6hdCnYMcKpIujEEo9SmMmK7Vnl29g1TCPO5tlrDNXq3Ng='), 27799517, 'df8ee44b0ed11108245037d47b511201') as client: @@ -68,10 +68,10 @@ class WebsiteTelegram(models.Model): users=[user_to_add.id], )) # message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=209&model=sale.order&view_type=form&cids=1&menu_id=101' - message = 'https://erp.indoteknik.com/web#id=' + self.id_data + '&action=357&model=sale.order&view_type=form&cids=1&menu_id=212' + 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 - result_massage = await client(SendMessageRequest(channel, message)) - result_massage2 = await client(SendMessageRequest(channel, message2)) + result_massage = await client(SendMessageRequest(channel, message_template)) + result_massage2 = await client(SendMessageRequest(channel, message)) # Send the poll to the channel using PeerChannel with the channel's ID # result_polling = await client(SendMediaRequest( -- cgit v1.2.3 From 1d5e4ca1fa58bcd59954a08b694f273d4c563cdf Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 31 Dec 2024 09:44:40 +0700 Subject: update telegram --- indoteknik_custom/models/website_telegram.py | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index 74955b7b..290fd1f9 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -21,7 +21,6 @@ class WebsiteTelegram(models.Model): tittle = fields.Char("Channel Title") invite_link = fields.Char("Channel invite link") username = fields.Char("Channel Name") - username_to_add = fields.Char("username to add on channel", compute='_compute_username_to_add') user_id = fields.Many2many('res.partner', string='User Member', store=True) id_data = fields.Char("Channel ID") about = fields.Char("Channel Description") @@ -31,15 +30,6 @@ class WebsiteTelegram(models.Model): # session_string = 'MIIBCgKCAQEAyMEdY1aR+sCR3ZSJrtztKTKqigvO/vBfqACJLZtS7QMgCGXJ6XIRyy7mx66W0/sOFa7/1mAZtEoIokDP3ShoqF4fVNb6XeqgQfaUHd8wJpDWHcR2OFwvplUUI1PLTktZ9uW2WE23b+ixNwJjJGwBDJPQEQFBE+vfmH0JP503wr5INS1poWg/j25sIWeYPHYeOrFp/eXaqhISP6G+q2IeTaWTXpwZj4LzXq5YOpk4bYEQ6mvRq7D1aHWfYmlEGepfaYR8Q0YqvvhYtMte3ITnuSJs171+GDqpdKcSwHnd6FudwGO4pcCOj4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB' - @api.depends('user_id') - def _compute_username_to_add(self): - for record in self: - usernames = [] - for partner in record.user_id: - if partner.telegram_id: # Pastikan mobile tidak None - usernames.append(partner.mobile) - # Gabungkan semua nomor menjadi satu string, dipisahkan koma - record.username_to_add = ', '.join(usernames) def create_channel(self, message): asyncio.run(self._async_create_channel(message)) -- cgit v1.2.3 From dc573e5c5f3922f0d0d031d616b779fa157fd679 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 16 Jan 2025 10:36:23 +0700 Subject: cr margin po --- indoteknik_custom/models/purchase_order.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 777e8ed2..d487ada3 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -965,7 +965,14 @@ class PurchaseOrder(models.Model): sales_price -= (sale_order_line.fee_third_party_line / sale_order_line.product_uom_qty) * line.qty_po sum_sales_price += sales_price - purchase_price = po_line.price_subtotal / po_line.product_qty * line.qty_po + + purchase_price = po_line.price_subtotal + if po_line.ending_price > 0: + if po_line.taxes_id.id == 22: + ending_price = po_line.ending_price / 1.11 + purchase_price = ending_price + else: + purchase_price = po_line.ending_price if line.purchase_order_id.delivery_amount > 0: purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po if line.purchase_order_id.delivery_amt > 0: -- cgit v1.2.3 From 40b0e30d359c917b6b22f6fb385a23026a7393bd Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 16 Jan 2025 14:41:54 +0700 Subject: update code deskripsi read only efek ke note --- indoteknik_custom/models/sale_order_line.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 29a046fa..aed95aab 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -38,11 +38,11 @@ class SaleOrderLine(models.Model): md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) margin_md = fields.Float(string='Margin MD') qty_free_bu = fields.Float(string='Free BU', compute='_get_qty_free_bandengan') - desc_updatable = fields.Boolean(string='desc boolean', default=False, compute='_get_desc_updatable') + desc_updatable = fields.Boolean(string='desc boolean', default=True, compute='_get_desc_updatable') def _get_desc_updatable(self): for line in self: - if line.product_id.id != 417724: + if line.product_id.id != 417724 and line.product_id.id: line.desc_updatable = False else: line.desc_updatable = True @@ -280,7 +280,7 @@ class SaleOrderLine(models.Model): (line.product_id.short_spesification if line.product_id.short_spesification else '') line.name = line_name line.weight = line.product_id.weight - if line.product_id.id != 417724: + if line.product_id.id != 417724 and line.product_id.id: line.desc_updatable = False else: line.desc_updatable = True -- cgit v1.2.3 From f6ff283a44e321f63822dbb2d302d3f3cb07baf5 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 16 Jan 2025 15:49:53 +0700 Subject: update pengajuan tempo dan tambah cek kredit limit --- indoteknik_custom/models/account_move_due_extension.py | 1 + indoteknik_custom/models/sale_order.py | 1 + indoteknik_custom/models/stock_picking.py | 1 + indoteknik_custom/models/user_pengajuan_tempo_request.py | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_due_extension.py b/indoteknik_custom/models/account_move_due_extension.py index 6fc58cdd..c48c2372 100644 --- a/indoteknik_custom/models/account_move_due_extension.py +++ b/indoteknik_custom/models/account_move_due_extension.py @@ -90,6 +90,7 @@ class DueExtension(models.Model): return self.order_id._create_approval_notification('Pimpinan') if self.order_id._requires_approval_margin_manager(): + self.order_id.check_credit_limit() self.order_id.approval_status = 'pengajuan1' return self.order_id._create_approval_notification('Sales Manager') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 7b2d9bf8..48195b77 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -816,6 +816,7 @@ class SaleOrder(models.Model): order.approval_status = 'pengajuan2' return self._create_approval_notification('Pimpinan') elif order._requires_approval_margin_manager(): + self.check_credit_limit() order.approval_status = 'pengajuan1' return self._create_approval_notification('Sales Manager') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index cd330aeb..0a65ab2d 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -121,6 +121,7 @@ class StockPicking(models.Model): ('cancel', 'Cancelled'), ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.") notee = fields.Text(string="Note") + date_done = fields.Date('Date done', String='Effective Date') @api.model def _compute_dokumen_tanda_terima(self): diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index f5261cd4..b43f56ac 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -332,7 +332,7 @@ class UserPengajuanTempoRequest(models.Model): self.pengajuan_tempo_id.dokumen_tempat_bekerja = self.dokumen_tempat_bekerja @api.onchange('tempo_duration') - def _tempo_duration_change(self, vals): + def _tempo_duration_change(self): for tempo in self: if tempo.env.user.id not in (7, 377, 12182): raise UserError("Durasi tempo hanya bisa di ubah oleh Sales Manager atau Direktur") -- cgit v1.2.3 From 3f8f8caaf847f193b084a4e08fbe46c00e98c831 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 16 Jan 2025 16:00:18 +0700 Subject: fix bug --- indoteknik_custom/models/stock_picking.py | 1 - 1 file changed, 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 0a65ab2d..cd330aeb 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -121,7 +121,6 @@ class StockPicking(models.Model): ('cancel', 'Cancelled'), ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.") notee = fields.Text(string="Note") - date_done = fields.Date('Date done', String='Effective Date') @api.model def _compute_dokumen_tanda_terima(self): -- cgit v1.2.3 From d1036cd456a53435be10f96714d9c93625cfe793 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 16 Jan 2025 16:05:28 +0700 Subject: delete validate export xml --- indoteknik_custom/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 4553e446..d62f19ae 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -353,7 +353,7 @@ class AccountMove(models.Model): def export_faktur_to_xml(self): - valid_invoices = self.validate_faktur_for_export() + valid_invoices = self # Panggil model coretax.faktur untuk menghasilkan XML coretax_faktur = self.env['coretax.faktur'].create({}) -- 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 ++- indoteknik_custom/models/website_telegram.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'indoteknik_custom/models') 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 -- cgit v1.2.3 From d4d24ffeff13b6169e0e3657c48990e45e80fd17 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 20 Jan 2025 13:35:37 +0700 Subject: delete clipboard modul import --- indoteknik_custom/models/website_telegram.py | 74 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/website_telegram.py b/indoteknik_custom/models/website_telegram.py index c655143e..c877a067 100644 --- a/indoteknik_custom/models/website_telegram.py +++ b/indoteknik_custom/models/website_telegram.py @@ -1,5 +1,5 @@ import requests -import clipboard +# import clipboard from odoo import models, fields, api from telethon.sessions import StringSession from telethon.sync import TelegramClient @@ -8,11 +8,11 @@ from telethon import functions, types from telethon.tl.types import InputPeerChannel import asyncio from telethon.tl.functions.messages import SendMessageRequest -from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, PeerChannel +# from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, PeerChannel import datetime from telethon.tl.types import MessageMediaPoll -from telethon.tl.functions.messages import SendMediaRequest -from telethon.tl.types import TextWithEntities +# from telethon.tl.functions.messages import SendMediaRequest +# from telethon.tl.types import TextWithEntities class WebsiteTelegram(models.Model): _name = 'website.telegram' @@ -148,39 +148,39 @@ class WebsiteTelegram(models.Model): except Exception as e: print(e) - @api.depends('name', 'chatID', 'bot_name') - def _calc_python_code(self): - for record in self: - if not record.name: - record.python_code = "pleas put a name" - elif not record.test_message: - record.test_message = "test" - else: - record.python_code = "self.env['website.telegram'].search([('name', '=', '" + record.name + "')])[0].send_to_telegram('" + record.test_message + "')" - - def copy_chat_id(self): - record = self.browse(self.id) - clipboard.copy(record.python_code) - - def paste_chat_id(self): - record = self.browse(self.id) - chat_id = clipboard.paste() - record.write({'chatID': chat_id}) - - def paste_bot_name(self): - record = self.browse(self.id) - bot_name = clipboard.paste() - record.write({'bot_name': bot_name}) - - def get_updates(self): - apiURL = f'https://api.telegram.org/bot{self.bot_name}/getUpdates' - try: - response = requests.get(apiURL) - updates = response.json() - return updates - except Exception as e: - print(e) - return None + # @api.depends('name', 'chatID', 'bot_name') + # def _calc_python_code(self): + # for record in self: + # if not record.name: + # record.python_code = "pleas put a name" + # elif not record.test_message: + # record.test_message = "test" + # else: + # record.python_code = "self.env['website.telegram'].search([('name', '=', '" + record.name + "')])[0].send_to_telegram('" + record.test_message + "')" + # + # def copy_chat_id(self): + # record = self.browse(self.id) + # clipboard.copy(record.python_code) + # + # def paste_chat_id(self): + # record = self.browse(self.id) + # chat_id = clipboard.paste() + # record.write({'chatID': chat_id}) + # + # def paste_bot_name(self): + # record = self.browse(self.id) + # bot_name = clipboard.paste() + # record.write({'bot_name': bot_name}) + # + # def get_updates(self): + # apiURL = f'https://api.telegram.org/bot{self.bot_name}/getUpdates' + # try: + # response = requests.get(apiURL) + # updates = response.json() + # return updates + # except Exception as e: + # print(e) + # return None # def receive_messages(self): # updates = self.get_updates() -- 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') 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') 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 d406e0cc949f8f35631d872993850f3ccec0821d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 20 Jan 2025 16:03:00 +0700 Subject: add other taxes in account move --- indoteknik_custom/models/account_move.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index d62f19ae..85ed1d54 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -63,6 +63,11 @@ class AccountMove(models.Model): flag_delivery_amt = fields.Boolean(string="Flag Delivery Amount", compute='compute_flag_delivery_amt') nomor_kwitansi = fields.Char(string="Nomor Kwitansi") other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal') + other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes') + + def compute_other_taxes(self): + for rec in self: + rec.other_taxes = rec.other_subtotal * 0.12 def compute_other_subtotal(self): for rec in 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') 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 9ae65ca732475a41f4055264b0e068bc607de759 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 21 Jan 2025 09:44:55 +0700 Subject: cr forecast --- .../models/report_stock_forecasted.py | 49 +--------------------- 1 file changed, 1 insertion(+), 48 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/report_stock_forecasted.py b/indoteknik_custom/models/report_stock_forecasted.py index c9d54a15..37082869 100644 --- a/indoteknik_custom/models/report_stock_forecasted.py +++ b/indoteknik_custom/models/report_stock_forecasted.py @@ -1,51 +1,4 @@ from odoo import api, models class ReplenishmentReport(models.AbstractModel): - _inherit = 'report.stock.report_product_product_replenishment' - - @api.model - def _get_report_lines(self, product_template_ids, product_variant_ids, wh_location_ids): - lines = super(ReplenishmentReport, self)._get_report_lines(product_template_ids, product_variant_ids, wh_location_ids) - # result_dict = {} - # - # for line in lines: - # document_out = line.get('document_out') - # - # if document_out and "SO/" in document_out.name: - # order_id = document_out.id - # if document_out == False: - # continue - # product_id = line.get('product', {}).get('id') - # query = [('product_id', '=', product_id)] - # - # if order_id: - # result = self._calculate_result(line) - # quantity = line.get('quantity', 0) - # result_dict.setdefault(order_id, []).append((result, quantity)) - # - # for order_id, results in result_dict.items(): - # sales_order = self.env['sale.order'].browse(order_id) - # - # for result, quantity in results: - # self.env['sales.order.fullfillment'].create({ - # 'sales_order_id': sales_order.id, - # 'product_id': product_id, - # 'reserved_from': result, - # 'qty_fullfillment': quantity, - # }) - return lines - - def _calculate_result(self, line): - if line['document_in']: - return str(line["document_in"].name) - elif line['reservation'] and not line['document_in']: - return 'Reserved from stock' - elif line['replenishment_filled']: - if line['document_out']: - return 'Inventory On Hand' - else: - return 'Free Stock' - else: - return 'Unfulfilled' - - + _inherit = 'report.stock.report_product_product_replenishment' \ No newline at end of file -- 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') 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 e3521c2153c36cee6629cee9146e1b4b0201da9f Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 21 Jan 2025 10:48:25 +0700 Subject: cr purchasing job --- indoteknik_custom/models/purchasing_job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index 4efb0cd4..74b5134e 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -182,7 +182,7 @@ class OutstandingSales(models.Model): join product_product pp on pp.id = sm.product_id join product_template pt on pt.id = pp.product_tmpl_id left join x_manufactures xm on xm.id = pt.x_manufacture - where sp.state in ('draft', 'waiting', 'confirmed', 'assigned') + where sp.state in ('draft', 'waiting', 'confirmed') and sp.name like '%OUT%' ) """) -- cgit v1.2.3 From e072cbf06a86cb376d71c0490f0f48c6de1fd3f7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 21 Jan 2025 14:41:19 +0700 Subject: fix pj --- indoteknik_custom/models/purchasing_job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index 74b5134e..4efb0cd4 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -182,7 +182,7 @@ class OutstandingSales(models.Model): join product_product pp on pp.id = sm.product_id join product_template pt on pt.id = pp.product_tmpl_id left join x_manufactures xm on xm.id = pt.x_manufacture - where sp.state in ('draft', 'waiting', 'confirmed') + where sp.state in ('draft', 'waiting', 'confirmed', 'assigned') and sp.name like '%OUT%' ) """) -- cgit v1.2.3 From 25ea83dd6a1f8ff272fd086a998904ed792b1041 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 21 Jan 2025 14:57:10 +0700 Subject: fix bug pj --- indoteknik_custom/models/purchasing_job.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index 4efb0cd4..902bc34b 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -183,6 +183,7 @@ class OutstandingSales(models.Model): join product_template pt on pt.id = pp.product_tmpl_id left join x_manufactures xm on xm.id = pt.x_manufacture where sp.state in ('draft', 'waiting', 'confirmed', 'assigned') + and sm.state in ('draft', 'waiting', 'confirmed', 'partially_available') and sp.name like '%OUT%' ) """) -- cgit v1.2.3 From afbdeb766a04d4c6d31d55151c02320f2b67c3fb Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 23 Jan 2025 09:58:19 +0700 Subject: update bisa edit limit dan durasi tambah ko step dan mba wid --- indoteknik_custom/models/user_pengajuan_tempo_request.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index b43f56ac..8023dfa7 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -334,13 +334,13 @@ class UserPengajuanTempoRequest(models.Model): @api.onchange('tempo_duration') def _tempo_duration_change(self): for tempo in self: - if tempo.env.user.id not in (7, 377, 12182): + if tempo.env.user.id not in (7, 688, 28, 377, 12182): raise UserError("Durasi tempo hanya bisa di ubah oleh Sales Manager atau Direktur") @api.onchange('tempo_limit') def _onchange_tempo_limit(self): for tempo in self: - if tempo.env.user.id not in (7, 377, 12182): + if tempo.env.user.id not in (7, 688, 28, 377, 12182): raise UserError("Limit tempo hanya bisa diubah oleh Sales Manager atau Direktur") def button_approve(self): for tempo in self: -- 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') 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') 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 From d61386fdd9e6082f66ba412dc5ad56e3ff3b2c08 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Jan 2025 09:48:27 +0700 Subject: cr chart of account journal entries --- indoteknik_custom/models/invoice_reklas.py | 4 ++-- indoteknik_custom/models/uangmuka_pembelian.py | 2 +- indoteknik_custom/models/uangmuka_penjualan.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/invoice_reklas.py b/indoteknik_custom/models/invoice_reklas.py index 30da02d1..f5bb5a25 100644 --- a/indoteknik_custom/models/invoice_reklas.py +++ b/indoteknik_custom/models/invoice_reklas.py @@ -49,7 +49,7 @@ class InvoiceReklas(models.TransientModel): if self.reklas_type == 'penjualan': parameter_debit = { 'move_id': account_move.id, - 'account_id': 449, # uang muka penjualan + 'account_id': 668, # penerimaan belum alokasi 'partner_id': invoice.partner_id.id, 'currency_id': 12, 'debit': self.pay_amt, @@ -77,7 +77,7 @@ class InvoiceReklas(models.TransientModel): } parameter_credit = { 'move_id': account_move.id, - 'account_id': 401, + 'account_id': 669, 'partner_id': invoice.partner_id.id, 'currency_id': 12, 'debit': 0, diff --git a/indoteknik_custom/models/uangmuka_pembelian.py b/indoteknik_custom/models/uangmuka_pembelian.py index 204855d3..ba41f814 100644 --- a/indoteknik_custom/models/uangmuka_pembelian.py +++ b/indoteknik_custom/models/uangmuka_pembelian.py @@ -64,7 +64,7 @@ class UangmukaPembelian(models.TransientModel): param_debit = { 'move_id': account_move.id, - 'account_id': 401, # uang muka persediaan barang dagang + 'account_id': 669, # uang muka persediaan barang dagang 'partner_id': partner_id, 'currency_id': 12, 'debit': self.pay_amt, diff --git a/indoteknik_custom/models/uangmuka_penjualan.py b/indoteknik_custom/models/uangmuka_penjualan.py index 5acf604d..a3e95ecd 100644 --- a/indoteknik_custom/models/uangmuka_penjualan.py +++ b/indoteknik_custom/models/uangmuka_penjualan.py @@ -74,7 +74,7 @@ class UangmukaPenjualan(models.TransientModel): # sisa di credit untuk uang muka penjualan, diluar ongkir dan selisih param_credit = { 'move_id': account_move.id, - 'account_id': 449, # uang muka penjualan + 'account_id': 668, # penerimaan belum alokasi 'partner_id': partner_id, 'currency_id': 12, 'debit': 0, -- cgit v1.2.3 From 1dd6174e739bb81c651ead6749200fcd09190ddc Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 24 Jan 2025 13:42:27 +0700 Subject: cr account id --- indoteknik_custom/models/invoice_reklas_penjualan.py | 2 +- indoteknik_custom/models/purchase_order.py | 4 ++-- indoteknik_custom/models/purchase_order_multi_uangmuka.py | 2 +- indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/invoice_reklas_penjualan.py b/indoteknik_custom/models/invoice_reklas_penjualan.py index 5027c8af..80c3ed43 100644 --- a/indoteknik_custom/models/invoice_reklas_penjualan.py +++ b/indoteknik_custom/models/invoice_reklas_penjualan.py @@ -33,7 +33,7 @@ class InvoiceReklasPenjualan(models.TransientModel): parameter_debit = { 'move_id': account_move.id, - 'account_id': 449, # uang muka penjualan + 'account_id': 668, # uang muka penjualan 'partner_id': invoice.partner_id.id, 'currency_id': 12, 'debit': invoice.pay_amt, diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index d487ada3..12a94730 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -178,7 +178,7 @@ class PurchaseOrder(models.Model): 'move_id': bills.id, 'product_id': product_dp.id, # product down payment 'name': '[IT.121456] Down Payment', # product down payment - 'account_id': 401, # Uang Muka persediaan barang dagang + 'account_id': 669, # Uang Muka persediaan barang dagang # 'price_unit': move_line.price_unit, 'quantity': -1, 'product_uom_id': 1, @@ -240,7 +240,7 @@ class PurchaseOrder(models.Model): data_line_bills = { 'move_id': bills.id, 'product_id': product_dp.id, # product down payment - 'account_id': 401, # Uang Muka persediaan barang dagang + 'account_id': 669, # Uang Muka persediaan barang dagang 'quantity': 1, 'product_uom_id': 1, 'tax_ids': [line[0].taxes_id.id for line in self.order_line], diff --git a/indoteknik_custom/models/purchase_order_multi_uangmuka.py b/indoteknik_custom/models/purchase_order_multi_uangmuka.py index dd63e698..0570efd9 100644 --- a/indoteknik_custom/models/purchase_order_multi_uangmuka.py +++ b/indoteknik_custom/models/purchase_order_multi_uangmuka.py @@ -76,7 +76,7 @@ class PurchaseOrderMultiUangmuka(models.TransientModel): param_debit = { 'move_id': account_move.id, - 'account_id': 401, # uang muka persediaan barang dagang + 'account_id': 669, # uang muka persediaan barang dagang 'partner_id': partner_id, 'currency_id': 12, 'debit': order.amount_total, diff --git a/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py b/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py index f9120290..96c2f676 100644 --- a/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py +++ b/indoteknik_custom/models/sale_order_multi_uangmuka_penjualan.py @@ -68,7 +68,7 @@ class PurchaseOrderMultiUangmukaPenjualan(models.TransientModel): param_credit = { 'move_id': account_move.id, - 'account_id': 449, # uang muka penjualan + 'account_id': 668, # penerimaan belum alokasi 'partner_id': partner_id, 'currency_id': 12, 'debit': 0, -- cgit v1.2.3 From ea81f5a5b5eedfffcfa15a3f752ccc81df6eed04 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 25 Jan 2025 10:34:13 +0700 Subject: CR automatic purchase brand stihl and mikasa --- indoteknik_custom/models/automatic_purchase.py | 141 +++++++++++++------------ 1 file changed, 73 insertions(+), 68 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 09d283eb..fbdf8dae 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -183,89 +183,94 @@ class AutomaticPurchase(models.Model): def create_po_by_vendor(self, vendor_id): current_time = datetime.now() - if not self.apo_type =='reordering': - name = "/PJ/" - else: - name = "/A/" + name = "/PJ/" if not self.apo_type == 'reordering' else "/A/" PRODUCT_PER_PO = 20 - auto_purchase_line = self.env['automatic.purchase.line'] - last_po = self.env['purchase.order'].search([ - ('partner_id', '=', vendor_id), - ('state', '=', 'done'), - ], order='id desc', limit=1) - - param_header = { - 'partner_id': vendor_id, - 'currency_id': 12, - 'user_id': self.env.user.id, - 'company_id': 1, # indoteknik dotcom gemilang - 'picking_type_id': 28, # indoteknik bandengan receipts - 'date_order': current_time, - 'from_apo': True, - 'note_description': 'Automatic PO' - } - + # Domain untuk semua baris dengan vendor_id tertentu domain = [ ('automatic_purchase_id', '=', self.id), ('partner_id', '=', vendor_id), ('qty_purchase', '>', 0) ] - products_len = auto_purchase_line.search_count(domain) - page = math.ceil(products_len / PRODUCT_PER_PO) - - # i start from zero (0) - for i in range(page): - new_po = self.env['purchase.order'].create([param_header]) - new_po.payment_term_id = new_po.partner_id.property_supplier_payment_term_id - new_po.name = new_po.name + name + str(i + 1) + # Tambahkan domain khusus untuk brand_id 22 dan 564 + special_brand_domain = domain + [('brand_id', 'in', [22, 564])] + regular_domain = domain + [('brand_id', 'not in', [22, 564])] + + # Fungsi untuk membuat PO berdasarkan domain tertentu + def create_po_for_domain(domain, special_payment_term=False): + products_len = auto_purchase_line.search_count(domain) + page = math.ceil(products_len / PRODUCT_PER_PO) + + for i in range(page): + # Buat PO baru + param_header = { + 'partner_id': vendor_id, + 'currency_id': 12, + 'user_id': self.env.user.id, + 'company_id': 1, # indoteknik dotcom gemilang + 'picking_type_id': 28, # indoteknik bandengan receipts + 'date_order': current_time, + 'from_apo': True, + 'note_description': 'Automatic PO' + } - self.env['automatic.purchase.match'].create([{ - 'automatic_purchase_id': self.id, - 'order_id': new_po.id - }]) + new_po = self.env['purchase.order'].create([param_header]) - lines = auto_purchase_line.search( - domain, - offset=i * PRODUCT_PER_PO, - limit=PRODUCT_PER_PO - ) + # Set payment_term_id khusus jika diperlukan + if special_payment_term: + new_po.payment_term_id = 29 + else: + new_po.payment_term_id = new_po.partner_id.property_supplier_payment_term_id - lines = auto_purchase_line.search( - domain, - offset=i * PRODUCT_PER_PO, - limit=PRODUCT_PER_PO - ) + new_po.name = new_po.name + name + str(i + 1) + self.env['automatic.purchase.match'].create([{ + 'automatic_purchase_id': self.id, + 'order_id': new_po.id + }]) + + # Ambil baris sesuai halaman + lines = auto_purchase_line.search( + domain, + offset=i * PRODUCT_PER_PO, + limit=PRODUCT_PER_PO + ) + + for line in lines: + product = line.product_id + sales_match = self.env['automatic.purchase.sales.match'].search([ + ('automatic_purchase_id', '=', self.id), + ('product_id', '=', product.id), + ]) + param_line = { + 'order_id': new_po.id, + 'product_id': product.id, + 'product_qty': line.qty_purchase, + 'qty_available_store': product.qty_available_bandengan, + 'suggest': product._get_po_suggest(line.qty_purchase), + 'product_uom_qty': line.qty_purchase, + 'price_unit': line.last_price, + 'ending_price': line.last_price, + 'taxes_id': [line.taxes_id.id] if line.taxes_id else None, + 'so_line_id': sales_match[0].sale_line_id.id if sales_match else None, + 'so_id': sales_match[0].sale_id.id if sales_match else None + } + new_po_line = self.env['purchase.order.line'].create([param_line]) + line.current_po_id = new_po.id + line.current_po_line_id = new_po_line.id + + self.create_purchase_order_sales_match(new_po) + + # Buat PO untuk special brand + if vendor_id == 23: + create_po_for_domain(special_brand_domain, special_payment_term=True) + + # Buat PO untuk regular domain + create_po_for_domain(regular_domain, "") - for line in lines: - product = line.product_id - sales_match = self.env['automatic.purchase.sales.match'].search([ - ('automatic_purchase_id', '=', self.id), - ('product_id', '=', product.id), - ]) - param_line = { - 'order_id': new_po.id, - 'product_id': product.id, - 'product_qty': line.qty_purchase, - 'qty_available_store': product.qty_available_bandengan, - 'suggest': product._get_po_suggest(line.qty_purchase), - 'product_uom_qty': line.qty_purchase, - 'price_unit': line.last_price, - 'ending_price': line.last_price, - 'taxes_id': [line.taxes_id.id] if line.taxes_id else None, - 'so_line_id': sales_match[0].sale_line_id.id if sales_match else None, - 'so_id': sales_match[0].sale_id.id if sales_match else None - } - new_po_line = self.env['purchase.order.line'].create([param_line]) - line.current_po_id = new_po.id - line.current_po_line_id = new_po_line.id - # self.update_purchase_price_so_line(line) - - self.create_purchase_order_sales_match(new_po) def update_purchase_price_so_line(self, apo): sales_match = self.env['automatic.purchase.sales.match'].search([ -- cgit v1.2.3 From 364eb8f589e5070c06e10bb5895e20e69dad8249 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 28 Jan 2025 15:23:38 +0700 Subject: add shipping_method_picking on sale order --- indoteknik_custom/models/sale_order.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 48195b77..98468c4b 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -144,6 +144,15 @@ class SaleOrder(models.Model): ('PNR', 'Pareto Non Repeating'), ('NP', 'Non Pareto') ]) + shipping_method_picking = fields.Char(string='Shipping Method Picking', compute='_compute_shipping_method_picking') + + def _compute_shipping_method_picking(self): + for order in self: + if order.picking_ids: + carrier_names = order.picking_ids.mapped('carrier_id.name') + order.shipping_method_picking = ', '.join(filter(None, carrier_names)) + else: + order.shipping_method_picking = False @api.onchange('payment_status') def _is_continue_transaction(self): -- cgit v1.2.3 From 888c71b3a5fe4ff4a338a2d13718b8624b1348d6 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 30 Jan 2025 09:32:05 +0700 Subject: update ambil tempo duration tempo --- indoteknik_custom/models/user_pengajuan_tempo_request.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 8023dfa7..29cf391c 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -71,7 +71,7 @@ class UserPengajuanTempoRequest(models.Model): website_tempo = fields.Char(string='Website', related='pengajuan_tempo_id.website_tempo', store=True, tracking=True, readonly=False) portal = fields.Boolean(string='Portal Website', related='pengajuan_tempo_id.portal', store=True, tracking=True, readonly=False) estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun', related='pengajuan_tempo_id.estimasi_tempo', store=True, tracking=True, readonly=False) - tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='pengajuan_tempo_id.tempo_duration', store=True, tracking=True, readonly=False, domain=[('id', 'in', [24, 25, 29, 32])]) + tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='tempo_duration', store=True, tracking=True, readonly=False, domain=[('id', 'in', [24, 25, 29, 32])]) tempo_limit_origin = fields.Char(string='Limit Tempo', related='pengajuan_tempo_id.tempo_limit' , store=True, tracking=True, readonly=False) category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', related='pengajuan_tempo_id.category_produk_ids', readonly=False) @@ -596,7 +596,7 @@ class UserPengajuanTempoRequest(models.Model): attachment_ids=[self.user_company_id.dokumen_tempat_bekerja.id]) # self.user_company_id.active = True # user.send_company_request_approve_mail() - self.user_company_id.property_payment_term_id = self.pengajuan_tempo_id.tempo_duration.id + self.user_company_id.property_payment_term_id = self.tempo_duration.id self.user_company_id.active_limit = True self.user_company_id.warning_stage = float(limit_tempo) - (float(limit_tempo)/2) self.user_company_id.blocking_stage = limit_tempo -- cgit v1.2.3 From dcbd88ea9ea1977c047425e31559fb2e5cee3de2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 30 Jan 2025 10:53:45 +0700 Subject: add validation on write and create function --- indoteknik_custom/models/product_template.py | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 29608297..d4b0abf4 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -67,6 +67,23 @@ class ProductTemplate(models.Model): print_barcode = fields.Boolean(string='Print Barcode', default=True) # qr_code = fields.Binary("QR Code", compute='_compute_qr_code') + @api.model + def create(self, vals): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + if self.env.user.id not in users_in_group.mapped('id'): + raise UserError('Hanya MD yang bisa membuat Product') + result = super(ProductTemplate, self).create(vals) + return result + + def write(self, values): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + if self.env.user.id not in users_in_group.mapped('id'): + raise UserError('Hanya MD yang bisa mengedit Product') + result = super(ProductTemplate, self).write(values) + return result + # def _compute_qr_code(self): # for rec in self.product_variant_ids: # qr = qrcode.QRCode( @@ -403,6 +420,23 @@ class ProductProduct(models.Model): merchandise_ok = fields.Boolean(string='Product Promotion') qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant') + @api.model + def create(self, vals): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + if self.env.user.id not in users_in_group.mapped('id'): + raise UserError('Hanya MD yang bisa membuat Product') + result = super(ProductProduct, self).create(vals) + return result + + def write(self, values): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + if self.env.user.id not in users_in_group.mapped('id'): + raise UserError('Hanya MD yang bisa mengedit Product') + result = super(ProductProduct, self).write(values) + return result + def _compute_qr_code_variant(self): for rec in self: # Skip inactive variants -- cgit v1.2.3 From f50f7d570eaa66552e6e91cfd9a29942a7ea3c36 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 30 Jan 2025 11:00:36 +0700 Subject: fix bug --- indoteknik_custom/models/product_template.py | 60 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index d4b0abf4..151513e8 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -67,22 +67,22 @@ class ProductTemplate(models.Model): print_barcode = fields.Boolean(string='Print Barcode', default=True) # qr_code = fields.Binary("QR Code", compute='_compute_qr_code') - @api.model - def create(self, vals): - group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - if self.env.user.id not in users_in_group.mapped('id'): - raise UserError('Hanya MD yang bisa membuat Product') - result = super(ProductTemplate, self).create(vals) - return result + # @api.model + # def create(self, vals): + # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + # if self.env.user.id not in users_in_group.mapped('id'): + # raise UserError('Hanya MD yang bisa membuat Product') + # result = super(ProductTemplate, self).create(vals) + # return result - def write(self, values): - group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - if self.env.user.id not in users_in_group.mapped('id'): - raise UserError('Hanya MD yang bisa mengedit Product') - result = super(ProductTemplate, self).write(values) - return result + # def write(self, values): + # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + # if self.env.user.id not in users_in_group.mapped('id'): + # raise UserError('Hanya MD yang bisa mengedit Product') + # result = super(ProductTemplate, self).write(values) + # return result # def _compute_qr_code(self): # for rec in self.product_variant_ids: @@ -420,22 +420,22 @@ class ProductProduct(models.Model): merchandise_ok = fields.Boolean(string='Product Promotion') qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant') - @api.model - def create(self, vals): - group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - if self.env.user.id not in users_in_group.mapped('id'): - raise UserError('Hanya MD yang bisa membuat Product') - result = super(ProductProduct, self).create(vals) - return result + # @api.model + # def create(self, vals): + # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + # if self.env.user.id not in users_in_group.mapped('id'): + # raise UserError('Hanya MD yang bisa membuat Product') + # result = super(ProductProduct, self).create(vals) + # return result - def write(self, values): - group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - if self.env.user.id not in users_in_group.mapped('id'): - raise UserError('Hanya MD yang bisa mengedit Product') - result = super(ProductProduct, self).write(values) - return result + # def write(self, values): + # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + # if self.env.user.id not in users_in_group.mapped('id'): + # raise UserError('Hanya MD yang bisa mengedit Product') + # result = super(ProductProduct, self).write(values) + # return result def _compute_qr_code_variant(self): for rec in self: -- cgit v1.2.3 From 2ceef7e7e73a91ee513787071ba4537c7c263349 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 30 Jan 2025 11:37:15 +0700 Subject: fix bug validation create and write --- indoteknik_custom/models/product_template.py | 64 +++++++++++++++------------- 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 151513e8..99a89d74 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -67,22 +67,24 @@ class ProductTemplate(models.Model): print_barcode = fields.Boolean(string='Print Barcode', default=True) # qr_code = fields.Binary("QR Code", compute='_compute_qr_code') - # @api.model - # def create(self, vals): - # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - # if self.env.user.id not in users_in_group.mapped('id'): - # raise UserError('Hanya MD yang bisa membuat Product') - # result = super(ProductTemplate, self).create(vals) - # return result + @api.model + def create(self, vals): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + active_model = self.env.context.get('active_model') + if self.env.user.id not in users_in_group.mapped('id') and active_model == None: + raise UserError('Hanya MD yang bisa membuat Product') + result = super(ProductTemplate, self).create(vals) + return result - # def write(self, values): - # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - # if self.env.user.id not in users_in_group.mapped('id'): - # raise UserError('Hanya MD yang bisa mengedit Product') - # result = super(ProductTemplate, self).write(values) - # return result + def write(self, values): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + active_model = self.env.context.get('active_model') + if self.env.user.id not in users_in_group.mapped('id') and active_model == None: + raise UserError('Hanya MD yang bisa mengedit Product') + result = super(ProductTemplate, self).write(values) + return result # def _compute_qr_code(self): # for rec in self.product_variant_ids: @@ -420,22 +422,24 @@ class ProductProduct(models.Model): merchandise_ok = fields.Boolean(string='Product Promotion') qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant') - # @api.model - # def create(self, vals): - # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - # if self.env.user.id not in users_in_group.mapped('id'): - # raise UserError('Hanya MD yang bisa membuat Product') - # result = super(ProductProduct, self).create(vals) - # return result + @api.model + def create(self, vals): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + active_model = self.env.context.get('active_model') + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + if self.env.user.id not in users_in_group.mapped('id') and active_model == None: + raise UserError('Hanya MD yang bisa membuat Product') + result = super(ProductProduct, self).create(vals) + return result - # def write(self, values): - # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - # if self.env.user.id not in users_in_group.mapped('id'): - # raise UserError('Hanya MD yang bisa mengedit Product') - # result = super(ProductProduct, self).write(values) - # return result + def write(self, values): + group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + active_model = self.env.context.get('active_model') + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + if self.env.user.id not in users_in_group.mapped('id') and active_model == None: + raise UserError('Hanya MD yang bisa mengedit Product') + result = super(ProductProduct, self).write(values) + return result def _compute_qr_code_variant(self): for rec in self: -- cgit v1.2.3 From b0152e913e55d4061abe1a0e96c558f62a99a830 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 30 Jan 2025 13:48:19 +0700 Subject: cr on account move line and add tracking on shipping paid by and shipping covered by on sale order --- indoteknik_custom/models/account_move_line.py | 6 ++++++ indoteknik_custom/models/sale_order.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index a4b25109..c4a65209 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -7,6 +7,12 @@ class AccountMoveLine(models.Model): cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre') is_required = fields.Boolean(string='Is Required', compute='_compute_is_required') analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') + line_no = fields.Integer('No', default=0, compute='_compute_line_no') + + def _compute_line_no(self): + if self.move_id: + for index, line in enumerate(self.move_id.invoice_line_ids, start=1): + line.line_no = index @api.onchange('account_id') def _onchange_account_id(self): diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 98468c4b..132aa397 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -28,11 +28,11 @@ class SaleOrder(models.Model): shipping_cost_covered = fields.Selection([ ('indoteknik', 'Indoteknik'), ('customer', 'Customer') - ], string='Shipping Covered by', help='Siapa yang menanggung biaya ekspedisi?', copy=False) + ], string='Shipping Covered by', help='Siapa yang menanggung biaya ekspedisi?', copy=False, tracking=3) shipping_paid_by = fields.Selection([ ('indoteknik', 'Indoteknik'), ('customer', 'Customer') - ], string='Shipping Paid by', help='Siapa yang talangin dulu Biaya ekspedisi-nya?', copy=False) + ], string='Shipping Paid by', help='Siapa yang talangin dulu Biaya ekspedisi-nya?', copy=False, tracking=3) sales_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) have_outstanding_invoice = fields.Boolean('Have Outstanding Invoice', compute='_have_outstanding_invoice') have_outstanding_picking = fields.Boolean('Have Outstanding Picking', compute='_have_outstanding_picking') -- cgit v1.2.3 From f1927a4220d546756bc3a1cc5666aa2ef2c8d816 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 30 Jan 2025 14:59:15 +0700 Subject: fix bug --- indoteknik_custom/models/product_template.py | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 99a89d74..efacb95f 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -77,14 +77,14 @@ class ProductTemplate(models.Model): result = super(ProductTemplate, self).create(vals) return result - def write(self, values): - group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - active_model = self.env.context.get('active_model') - if self.env.user.id not in users_in_group.mapped('id') and active_model == None: - raise UserError('Hanya MD yang bisa mengedit Product') - result = super(ProductTemplate, self).write(values) - return result + # def write(self, values): + # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + # active_model = self.env.context.get('active_model') + # if self.env.user.id not in users_in_group.mapped('id') and active_model == None: + # raise UserError('Hanya MD yang bisa mengedit Product') + # result = super(ProductTemplate, self).write(values) + # return result # def _compute_qr_code(self): # for rec in self.product_variant_ids: @@ -432,14 +432,14 @@ class ProductProduct(models.Model): result = super(ProductProduct, self).create(vals) return result - def write(self, values): - group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - active_model = self.env.context.get('active_model') - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - if self.env.user.id not in users_in_group.mapped('id') and active_model == None: - raise UserError('Hanya MD yang bisa mengedit Product') - result = super(ProductProduct, self).write(values) - return result + # def write(self, values): + # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + # active_model = self.env.context.get('active_model') + # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + # if self.env.user.id not in users_in_group.mapped('id') and active_model == None: + # raise UserError('Hanya MD yang bisa mengedit Product') + # result = super(ProductProduct, self).write(values) + # return result def _compute_qr_code_variant(self): for rec in self: -- cgit v1.2.3 From b547143489e5bef27425199b36a9dd3984429421 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 30 Jan 2025 15:35:20 +0700 Subject: label entries line same with ref move entry --- indoteknik_custom/models/account_move.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 85ed1d54..7760c69d 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -65,6 +65,13 @@ class AccountMove(models.Model): other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal') other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes') + def _update_line_name_from_ref(self): + """Update all account.move.line name fields with ref from account.move""" + for move in self: + if move.move_type == 'entry' and move.ref and move.line_ids: + for line in move.line_ids: + line.name = move.ref + def compute_other_taxes(self): for rec in self: rec.other_taxes = rec.other_subtotal * 0.12 @@ -107,6 +114,7 @@ class AccountMove(models.Model): def create(self, vals): vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' result = super(AccountMove, self).create(vals) + result._update_line_name_from_ref() return result def compute_so_shipping_paid_by(self): -- cgit v1.2.3 From d7a18a90adc0502831eabd1e5940677161ddd4bf Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 30 Jan 2025 16:56:07 +0700 Subject: add filter searching picking on report logbook sj --- indoteknik_custom/models/report_logbook_sj.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py index a1b6299c..17119c12 100644 --- a/indoteknik_custom/models/report_logbook_sj.py +++ b/indoteknik_custom/models/report_logbook_sj.py @@ -29,6 +29,8 @@ class ReportLogbookSJ(models.Model): string='Status', tracking=True, ) + + sj_number = fields.Char(string='Picking', related='report_logbook_sj_line.name') count_line = fields.Char(string='Count Line', compute='_compute_count_line') -- cgit v1.2.3 From de4404c4b60b0859a4cbae836cc4c99d806bf697 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 31 Jan 2025 10:01:49 +0700 Subject: fix bug --- indoteknik_custom/models/account_move_line.py | 2 +- indoteknik_custom/models/stock_picking.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index c4a65209..9ab9620b 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -10,7 +10,7 @@ class AccountMoveLine(models.Model): line_no = fields.Integer('No', default=0, compute='_compute_line_no') def _compute_line_no(self): - if self.move_id: + if self.move_id and self.move_id.move_type == 'out_invoice': for index, line in enumerate(self.move_id.invoice_line_ids, start=1): line.line_no = index diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index cc86c451..9af74cd3 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -467,7 +467,7 @@ class StockPicking(models.Model): def check_state_reserve(self): pickings = self.search([ - ('state', 'not in', ['cancel', 'draft', 'done']), + ('state', 'not in', ['cancel', 'done']), ('picking_type_code', '=', 'outgoing') ]) -- cgit v1.2.3 From c131fcf6f0fd3aa8bd4d3a241aabe577bbf57137 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 31 Jan 2025 10:19:45 +0700 Subject: fix bug --- indoteknik_custom/models/account_move_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 9ab9620b..c4a65209 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -10,7 +10,7 @@ class AccountMoveLine(models.Model): line_no = fields.Integer('No', default=0, compute='_compute_line_no') def _compute_line_no(self): - if self.move_id and self.move_id.move_type == 'out_invoice': + if self.move_id: for index, line in enumerate(self.move_id.invoice_line_ids, start=1): line.line_no = index -- cgit v1.2.3 From 9b4b186d5ac43f1e823ddf37d60f37980f3e721c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 31 Jan 2025 10:27:51 +0700 Subject: fix bug --- indoteknik_custom/models/account_move_line.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index c4a65209..568c9b85 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -9,9 +9,10 @@ class AccountMoveLine(models.Model): analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') line_no = fields.Integer('No', default=0, compute='_compute_line_no') + @api.depends('move_id.invoice_line_ids') def _compute_line_no(self): - if self.move_id: - for index, line in enumerate(self.move_id.invoice_line_ids, start=1): + for move in self.mapped('move_id'): + for index, line in enumerate(move.invoice_line_ids, start=1): line.line_no = index @api.onchange('account_id') -- cgit v1.2.3 From 8cba896edb13b2b2911e487aea562553d3b17025 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 31 Jan 2025 10:34:41 +0700 Subject: trying to fix bug --- indoteknik_custom/models/account_move_line.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 568c9b85..3c352560 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -12,9 +12,12 @@ class AccountMoveLine(models.Model): @api.depends('move_id.invoice_line_ids') def _compute_line_no(self): for move in self.mapped('move_id'): - for index, line in enumerate(move.invoice_line_ids, start=1): - line.line_no = index - + if move.move_type == 'out_invoice' and move.invoice_line_ids: + for index, line in enumerate(move.invoice_line_ids, start=1): + line.line_no = index + else: + for index, line in enumerate(move.line_ids, start=1): + line.line_no = index @api.onchange('account_id') def _onchange_account_id(self): for account in self: -- cgit v1.2.3 From 57b2ce27d2892f04e0503ac4543d23245bee639e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 31 Jan 2025 11:00:25 +0700 Subject: fix bug --- indoteknik_custom/models/account_move_line.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 3c352560..37f7c77c 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -7,17 +7,8 @@ class AccountMoveLine(models.Model): cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre') is_required = fields.Boolean(string='Is Required', compute='_compute_is_required') analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') - line_no = fields.Integer('No', default=0, compute='_compute_line_no') + line_no = fields.Integer('No', default=0) - @api.depends('move_id.invoice_line_ids') - def _compute_line_no(self): - for move in self.mapped('move_id'): - if move.move_type == 'out_invoice' and move.invoice_line_ids: - for index, line in enumerate(move.invoice_line_ids, start=1): - line.line_no = index - else: - for index, line in enumerate(move.line_ids, start=1): - line.line_no = index @api.onchange('account_id') def _onchange_account_id(self): for account in self: -- cgit v1.2.3 From b4249a4dbed1f982ce2355ea7b8245dd1c44da8d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 31 Jan 2025 11:20:33 +0700 Subject: fix send mail bills --- indoteknik_custom/models/stock_immediate_transfer.py | 1 - indoteknik_custom/models/stock_picking.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_immediate_transfer.py b/indoteknik_custom/models/stock_immediate_transfer.py index 4be0dff2..21210619 100644 --- a/indoteknik_custom/models/stock_immediate_transfer.py +++ b/indoteknik_custom/models/stock_immediate_transfer.py @@ -16,7 +16,6 @@ class StockImmediateTransfer(models.TransientModel): pickings_not_to_do |= line.picking_id for picking in pickings_to_do: - picking.send_mail_bills() # If still in draft => confirm and assign if picking.state == 'draft': picking.action_confirm() diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 9af74cd3..ce198be3 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -811,6 +811,7 @@ class StockPicking(models.Model): self.calculate_line_no() self.date_done = datetime.datetime.utcnow() self.state_reserve = 'done' + self.send_mail_bills() return res -- cgit v1.2.3 From dd0158651c5fa665cde6c534e7f4283f86adafc9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 3 Feb 2025 14:46:38 +0700 Subject: add type on barcoding product --- indoteknik_custom/models/barcoding_product.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/barcoding_product.py b/indoteknik_custom/models/barcoding_product.py index 6bbf9fde..e1b8f41f 100644 --- a/indoteknik_custom/models/barcoding_product.py +++ b/indoteknik_custom/models/barcoding_product.py @@ -12,6 +12,14 @@ class BarcodingProduct(models.Model): barcoding_product_line = fields.One2many('barcoding.product.line', 'barcoding_product_id', string='Barcoding Product Lines', auto_join=True) product_id = fields.Many2one('product.product', string="Product", tracking=3) quantity = fields.Float(string="Quantity", tracking=3) + type = fields.Selection([('print', 'Print Barcode'), ('barcoding', 'Add Barcode To Product')], string='Type', default='print') + barcode = fields.Char(string="Barcode") + + @api.constrains('barcode') + def _send_barcode_to_product(self): + for record in self: + if record.barcode and not record.product_id.barcode: + record.product_id.barcode = record.barcode @api.onchange('product_id', 'quantity') def _onchange_product_or_quantity(self): -- cgit v1.2.3 From 8cf663b15d39a04df97b3ef13f76b407ca6b7004 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Tue, 4 Feb 2025 08:55:01 +0700 Subject: xoretax xml add code barang --- indoteknik_custom/models/coretax_fatur.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index ae6dd2ae..706a4f44 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -77,7 +77,7 @@ class CoretaxFaktur(models.Model): otherTaxBase = round(line.price_subtotal * (11/12)) if line.price_subtotal else 0 good_service = ET.SubElement(list_of_good_service, 'GoodService') ET.SubElement(good_service, 'Opt').text = 'A' - ET.SubElement(good_service, 'Code') + ET.SubElement(good_service, 'Code').text = '000000' ET.SubElement(good_service, 'Name').text = line.name ET.SubElement(good_service, 'Unit').text = 'UM.0018' ET.SubElement(good_service, 'Price').text = str(round(line.price_subtotal/line.quantity, 2)) if line.price_subtotal else '0' -- cgit v1.2.3 From 0bf3a1d1db07ee8306d81443cc4dba94b3740808 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 4 Feb 2025 15:35:41 +0700 Subject: update code sale order --- indoteknik_custom/models/sale_order.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 132aa397..4bdd9f2c 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -980,6 +980,7 @@ class SaleOrder(models.Model): def action_confirm(self): for order in self: + order.check_credit_limit() if self.validate_different_vendor() and not self.vendor_approval: return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor') -- cgit v1.2.3 From 43d859b6c51697a8cff9f543154934ea045d1378 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 6 Feb 2025 10:06:40 +0700 Subject: ubah logic warning limit --- indoteknik_custom/models/user_pengajuan_tempo_request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 29cf391c..b6103bbb 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -598,8 +598,8 @@ class UserPengajuanTempoRequest(models.Model): # user.send_company_request_approve_mail() self.user_company_id.property_payment_term_id = self.tempo_duration.id self.user_company_id.active_limit = True - self.user_company_id.warning_stage = float(limit_tempo) - (float(limit_tempo)/2) self.user_company_id.blocking_stage = limit_tempo + self.user_company_id.warning_stage = float(limit_tempo) - (float(limit_tempo)/2) # Internal Notes comment = [] -- cgit v1.2.3 From f78fcf1c60160540221e240338acc54dfc9beb74 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 6 Feb 2025 11:22:06 +0700 Subject: add po count on po and add validation duplicate contact --- indoteknik_custom/models/purchase_order.py | 1 + indoteknik_custom/models/res_partner.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 12a94730..54d771ba 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -86,6 +86,7 @@ class PurchaseOrder(models.Model): total_cost_service = fields.Float(string='Total Cost Service') total_delivery_amt = fields.Float(string='Total Delivery Amt') store_name = fields.Char(string='Nama Toko') + purchase_order_count = fields.Integer('Purchase Order Count', related='partner_id.purchase_order_count') @api.onchange('total_cost_service') def _onchange_total_cost_service(self): diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 5322515a..3c5e0e05 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -183,6 +183,19 @@ class ResPartner(models.Model): # # raise UserError('You name it') # return res + + @api.constrains('name') + def _check_duplicate_name(self): + for record in self: + if record.name: + # Mencari partner lain yang memiliki nama sama (case-insensitive) + existing_partner = self.env['res.partner'].search([ + ('id', '!=', record.id), # Hindari mencocokkan diri sendiri + ('name', 'ilike', record.name) # Case-insensitive search + ], limit=1) + + if existing_partner: + raise ValidationError(f"Nama '{record.name}' sudah digunakan oleh partner lain!") def write(self, vals): # Fungsi rekursif untuk meng-update semua child, termasuk child dari child -- cgit v1.2.3 From 11ef44bdb2695125048fe7fcfea25dbf459a3d9e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 6 Feb 2025 13:14:25 +0700 Subject: add levenshtein to duplikat name contact alert --- indoteknik_custom/models/res_partner.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 3c5e0e05..844d47f9 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -188,14 +188,17 @@ class ResPartner(models.Model): def _check_duplicate_name(self): for record in self: if record.name: - # Mencari partner lain yang memiliki nama sama (case-insensitive) - existing_partner = self.env['res.partner'].search([ - ('id', '!=', record.id), # Hindari mencocokkan diri sendiri - ('name', 'ilike', record.name) # Case-insensitive search - ], limit=1) - - if existing_partner: - raise ValidationError(f"Nama '{record.name}' sudah digunakan oleh partner lain!") + query = """ + SELECT name FROM res_partner + WHERE id != %s + AND levenshtein(lower(name), lower(%s)) <= 1 + LIMIT 1 + """ + self.env.cr.execute(query, (record.id, record.name)) + duplicate = self.env.cr.fetchone() + + if duplicate: + raise ValidationError(f"Nama '{record.name}' mirip dengan '{duplicate[0]}', harap gunakan nama yang unik!") def write(self, vals): # Fungsi rekursif untuk meng-update semua child, termasuk child dari child -- cgit v1.2.3 From 1abbebda5ab707b014e8e01a7ab418861beef420 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 6 Feb 2025 16:40:34 +0700 Subject: cr validation duplicate contact --- indoteknik_custom/models/res_partner.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 844d47f9..7e574a72 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -188,17 +188,14 @@ class ResPartner(models.Model): def _check_duplicate_name(self): for record in self: if record.name: - query = """ - SELECT name FROM res_partner - WHERE id != %s - AND levenshtein(lower(name), lower(%s)) <= 1 - LIMIT 1 - """ - self.env.cr.execute(query, (record.id, record.name)) - duplicate = self.env.cr.fetchone() - - if duplicate: - raise ValidationError(f"Nama '{record.name}' mirip dengan '{duplicate[0]}', harap gunakan nama yang unik!") + # Mencari partner lain yang memiliki nama sama (case-insensitive) + existing_partner = self.env['res.partner'].search([ + ('id', '!=', record.id), # Hindari mencocokkan diri sendiri + ('name', '=', record.name) # Case-insensitive search + ], limit=1) + + if existing_partner: + raise ValidationError(f"Nama '{record.name}' sudah digunakan oleh partner lain!") def write(self, vals): # Fungsi rekursif untuk meng-update semua child, termasuk child dari child -- cgit v1.2.3 From 3187466a66abb41931e346e7865dfa6432f3da9e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 7 Feb 2025 14:24:02 +0700 Subject: add chek kredit limit tapi ditambah dengan so yang to invoice --- indoteknik_custom/models/sale_order.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 4bdd9f2c..0d2e42cb 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -768,6 +768,7 @@ class SaleOrder(models.Model): def sale_order_approve(self): self.check_credit_limit() + self.check_limit_so_to_invoice() if self.validate_different_vendor() and not self.vendor_approval: return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor') self.check_due() @@ -826,6 +827,7 @@ class SaleOrder(models.Model): return self._create_approval_notification('Pimpinan') elif order._requires_approval_margin_manager(): self.check_credit_limit() + self.check_limit_so_to_invoice() order.approval_status = 'pengajuan1' return self._create_approval_notification('Sales Manager') @@ -932,6 +934,28 @@ class SaleOrder(models.Model): raise UserError(_("%s is in Blocking Stage, Remaining credit limit is %s, from %s and outstanding %s") % (rec.partner_id.name, remaining_credit_limit, block_stage, outstanding_amount)) + def check_limit_so_to_invoice(self): + for rec in self: + # Ambil jumlah outstanding_amount dan rec.amount_total sebagai current_total + outstanding_amount = rec.outstanding_amount + current_total = rec.amount_total + outstanding_amount + + # Ambil blocking stage dari partner + block_stage = rec.partner_id.parent_id.blocking_stage if rec.partner_id.parent_id else rec.partner_id.blocking_stage or 0 + + # Ambil jumlah nilai dari SO yang invoice_status masih 'to invoice' + so_to_invoice = 0 + for sale in rec.partner_id.sale_order_ids: + if sale.invoice_status == 'to invoice': + so_to_invoice = so_to_invoice + sale.amount_total + # Hitung remaining credit limit + remaining_credit_limit = block_stage - current_total - so_to_invoice + + # Validasi limit + if remaining_credit_limit <= 0: + raise UserError(_("The credit limit for %s will exceed the Blocking Stage if the Sale Order is confirmed. The remaining credit limit is %s, from %s and the outstanding amount is %s.") + % (rec.partner_id.name, block_stage - current_total, block_stage, outstanding_amount)) + def validate_different_vendor(self): if self.vendor_approval_id.filtered(lambda v: v.state == 'draft'): draft_names = ", ".join(self.vendor_approval_id.filtered(lambda v: v.state == 'draft').mapped('number')) @@ -981,6 +1005,7 @@ class SaleOrder(models.Model): def action_confirm(self): for order in self: order.check_credit_limit() + order.check_limit_so_to_invoice() if self.validate_different_vendor() and not self.vendor_approval: return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor') -- cgit v1.2.3 From ae66937628c5431274df26183674cad52f90c029 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 7 Feb 2025 14:57:43 +0700 Subject: disallow some state while cancel sales order --- indoteknik_custom/models/sale_order.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 0d2e42cb..2f3871ad 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1067,9 +1067,14 @@ class SaleOrder(models.Model): if self.have_outstanding_invoice: raise UserError("Invoice harus di Cancel dahulu") + + disallow_states = ['draft', 'waiting', 'confirmed', 'assigned'] + for picking in self.picking_ids: + if picking.state in disallow_states: + raise UserError("DO yang draft, waiting, confirmed, atau assigned harus di-cancel oleh Logistik") for line in self.order_line: if line.qty_delivered > 0: - raise UserError("DO harus di-cancel terlebih dahulu.") + raise UserError("DO yang done harus di-Return oleh Logistik") if not self.web_approval: self.web_approval = 'company' -- cgit v1.2.3 From e960a38aa69fbd7a75b6f06a3b30967d8b20ddd5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 10 Feb 2025 09:45:03 +0700 Subject: fix bug create payment link --- indoteknik_custom/models/sale_order.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 2f3871ad..5c223beb 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -549,22 +549,22 @@ class SaleOrder(models.Model): redirect_url = json.loads(lookup_json)['redirect_url'] self.payment_link_midtrans = str(redirect_url) - # Generate QR code - qr = qrcode.QRCode( - version=1, - error_correction=qrcode.constants.ERROR_CORRECT_L, - box_size=10, - border=4, - ) - qr.add_data(redirect_url) - qr.make(fit=True) - img = qr.make_image(fill_color="black", back_color="white") - - buffer = BytesIO() - img.save(buffer, format="PNG") - qr_code_img = base64.b64encode(buffer.getvalue()).decode() - - self.payment_qr_code = qr_code_img + if 'redirect_url' in response: + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=4, + ) + qr.add_data(redirect_url) + qr.make(fit=True) + img = qr.make_image(fill_color="black", back_color="white") + + buffer = BytesIO() + img.save(buffer, format="PNG") + qr_code_img = base64.b64encode(buffer.getvalue()).decode() + + self.payment_qr_code = qr_code_img @api.model def _generate_so_access_token(self, limit=50): -- cgit v1.2.3 From 3d5e57a2d892551965bcf079f7c728d00989af8e Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 10 Feb 2025 14:05:12 +0700 Subject: update make contak from tempo --- .../models/user_pengajuan_tempo_request.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index b6103bbb..81509df4 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -507,10 +507,20 @@ class UserPengajuanTempoRequest(models.Model): # Buat kontak baru untuk company_id for contact_data in contacts_data: - self.env['res.partner'].create({ - "parent_id": self.user_company_id.id, # Hubungkan ke perusahaan - **contact_data, # Tambahkan data kontak - }) + existing_contact = self.env['res.partner'].search([ + ('parent_id', '=', self.user_company_id.id), + ('name', '=', contact_data['name']) + ], limit=1) + + if existing_contact: + # Perbarui data yang ada + existing_contact.write(contact_data) + else: + # Buat kontak baru jika belum ada + self.env['res.partner'].create({ + "parent_id": self.user_company_id.id, # Hubungkan ke perusahaan + **contact_data, # Tambahkan data kontak + }) # Pengiriman self.user_company_id.pic_name = self.pengajuan_tempo_id.pic_name -- cgit v1.2.3 From 8a29d6ef46d15fbce033b94464e139cabb8aeb68 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 10 Feb 2025 14:23:02 +0700 Subject: update yg sama --- indoteknik_custom/models/user_pengajuan_tempo_request.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 81509df4..3f960e58 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -513,8 +513,9 @@ class UserPengajuanTempoRequest(models.Model): ], limit=1) if existing_contact: - # Perbarui data yang ada - existing_contact.write(contact_data) + # Perbarui hanya field yang tidak menyebabkan konflik + update_data = {k: v for k, v in contact_data.items() if k != 'name'} + existing_contact.write(update_data) else: # Buat kontak baru jika belum ada self.env['res.partner'].create({ -- cgit v1.2.3 From 1ff643c37772d573b5bf4c1814c85cf442de1863 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 10 Feb 2025 15:05:14 +0700 Subject: update logic add contact tempo(revisi) --- .../models/user_pengajuan_tempo_request.py | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 3f960e58..0b77cc87 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -513,11 +513,28 @@ class UserPengajuanTempoRequest(models.Model): ], limit=1) if existing_contact: - # Perbarui hanya field yang tidak menyebabkan konflik - update_data = {k: v for k, v in contact_data.items() if k != 'name'} - existing_contact.write(update_data) + # Pastikan tidak ada duplikasi nama dalam perusahaan yang sama + duplicate_check = self.env['res.partner'].search([ + ('name', '=', contact_data['name']), + ('id', '!=', existing_contact.id) # Hindari update yang menyebabkan duplikasi global + ], limit=1) + + if not duplicate_check: + # Perbarui hanya field yang tidak menyebabkan konflik + update_data = {k: v for k, v in contact_data.items() if k != 'name'} + existing_contact.write(update_data) + else: + raise UserError(f"Skipping update for {contact_data['name']} due to existing duplicate.") else: - # Buat kontak baru jika belum ada + # Pastikan tidak ada partner lain dengan nama yang sama sebelum membuat baru + duplicate_check = self.env['res.partner'].search([ + ('name', '=', contact_data['name']) + ], limit=1) + + if duplicate_check: + # Jika nama sudah ada tetapi di perusahaan lain, tambahkan nama perusahaan + contact_data['name'] = f"{contact_data['name']} ({self.user_company_id.name})" + self.env['res.partner'].create({ "parent_id": self.user_company_id.id, # Hubungkan ke perusahaan **contact_data, # Tambahkan data kontak -- cgit v1.2.3 From 84c259bb2c579a0ad1f1593d7d3d7bf57fb732f0 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 10 Feb 2025 16:55:44 +0700 Subject: add tracking reason reject tempo --- indoteknik_custom/models/user_pengajuan_tempo_request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 0b77cc87..e2c08cb2 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -7,7 +7,7 @@ class RejectReasonWizard(models.TransientModel): _description = 'Wizard for Reject Reason' request_id = fields.Many2one('user.pengajuan.tempo.request', string='Request') - reason_reject = fields.Text(string='Reason for Rejection', required=True) + reason_reject = fields.Text(string='Reason for Rejection', required=True, tracking=True) def confirm_reject(self): tempo = self.request_id -- cgit v1.2.3 From e7eadc269299d03f6eb0702459147a2900b982b4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 11 Feb 2025 09:03:25 +0700 Subject: update code blocking state --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 5c223beb..9631fe6e 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -952,7 +952,7 @@ class SaleOrder(models.Model): remaining_credit_limit = block_stage - current_total - so_to_invoice # Validasi limit - if remaining_credit_limit <= 0: + if remaining_credit_limit <= 0 and block_stage > 0: raise UserError(_("The credit limit for %s will exceed the Blocking Stage if the Sale Order is confirmed. The remaining credit limit is %s, from %s and the outstanding amount is %s.") % (rec.partner_id.name, block_stage - current_total, block_stage, outstanding_amount)) -- cgit v1.2.3 From 751645803b13cbc96d4a554a9c9d8a63cd991486 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 11 Feb 2025 13:45:07 +0700 Subject: fix bug state reserve --- indoteknik_custom/models/stock_picking.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index ce198be3..b1b1bdb8 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -467,19 +467,19 @@ class StockPicking(models.Model): def check_state_reserve(self): pickings = self.search([ - ('state', 'not in', ['cancel', 'done']), + ('state', 'not in', ['cancel', 'draft', 'done']), ('picking_type_code', '=', 'outgoing') ]) for picking in pickings: - fullfillments = self.env['sales.order.fullfillment'].search([ - ('sales_order_id', '=', picking.sale_id.id) + fullfillments = self.env['sales.order.fulfillment.v2'].search([ + ('sale_order_id', '=', picking.sale_id.id) ]) picking.state_reserve = 'ready' picking.date_reserved = picking.date_reserved or datetime.datetime.utcnow() - if any(rec.reserved_from not in ['Inventory On Hand', 'Reserved from stock', 'Free Stock'] for rec in fullfillments): + if any(rec.so_qty != rec.reserved_stock_qty for rec in fullfillments): picking.state_reserve = 'waiting' picking.date_reserved = '' -- cgit v1.2.3 From ede74761c8556b18b4555af22738a76538682512 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 11 Feb 2025 14:52:22 +0700 Subject: add CR cancel so >30jt --- indoteknik_custom/models/sale_order.py | 73 +++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 9631fe6e..b1039750 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -7,6 +7,44 @@ from collections import defaultdict _logger = logging.getLogger(__name__) +class CancelReasonOrder(models.TransientModel): + _name = 'cancel.reason.order' + _description = 'Wizard for Cancel Reason order' + + request_id = fields.Many2one('sale.order', string='Request') + reason_cancel = fields.Selection([ + ('harga_terlalu_mahal', 'Harga barang terlalu mahal'), + ('harga_web_tidak_valid', 'Harga web tidak valid'), + ('stok_kosong', 'Stock kosong'), + ('tidak_mau_indent', 'Customer tidak mau indent'), + ('batal_rencana_pembelian', 'Customer membatalkan rencana pembelian'), + ('vendor_tidak_support_demo', 'Vendor tidak support demo/trial product'), + ('product_knowledge_kurang', 'Product knowledge kurang baik'), + ('barang_tidak_sesuai', 'Barang tidak sesuai/tepat'), + ('tidak_sepakat_pembayaran', 'Tidak menemukan kesepakatan untuk pembayaran'), + ('dokumen_tidak_support', 'Indoteknik tidak bisa support document yang dibutuhkan (Ex: TKDN, COO, SNI)'), + ('ganti_quotation', 'Ganti Quotation'), + ('testing_internal', 'Testing Internal'), + ], string='Reason for Cancel', required=True, copy=False, index=True, tracking=3) + attachment_bukti = fields.Many2many( + 'ir.attachment', + string="Attachment Bukti", readonly=False, + tracking=3, required=True + ) + nomor_so_pengganti = fields.Char(string='Nomor SO Pengganti', copy=False, tracking=3) + + def confirm_reject(self): + order = self.request_id + if order: + order.write({'reason_cancel': self.reason_cancel}) + order.write({'attachment_bukti': self.attachment_bukti}) + order.message_post(body='Attachment Bukti Cancel', + attachment_ids=[self.attachment_bukti.id]) + if self.nomor_so_pengganti or self.reason_cancel == 'ganti_quotation': + order.write({'nomor_so_pengganti': self.nomor_so_pengganti}) + order.confirm_cancel_order() + + return {'type': 'ir.actions.act_window_close'} class SaleOrder(models.Model): _inherit = "sale.order" @@ -145,6 +183,25 @@ class SaleOrder(models.Model): ('NP', 'Non Pareto') ]) shipping_method_picking = fields.Char(string='Shipping Method Picking', compute='_compute_shipping_method_picking') + reason_cancel = fields.Selection([ + ('harga_terlalu_mahal', 'Harga barang terlalu mahal'), + ('harga_web_tidak_valid', 'Harga web tidak valid'), + ('stok_kosong', 'Stock kosong'), + ('tidak_mau_indent', 'Customer tidak mau indent'), + ('batal_rencana_pembelian', 'Customer membatalkan rencana pembelian'), + ('vendor_tidak_support_demo', 'Vendor tidak support demo/trial product'), + ('product_knowledge_kurang', 'Product knowledge kurang baik'), + ('barang_tidak_sesuai', 'Barang tidak sesuai/tepat'), + ('tidak_sepakat_pembayaran', 'Tidak menemukan kesepakatan untuk pembayaran'), + ('dokumen_tidak_support', 'Indoteknik tidak bisa support document yang dibutuhkan (Ex: TKDN, COO, SNI)'), + ('ganti_quotation', 'Ganti Quotation'), + ('testing_internal', 'Testing Internal'), + ], string='Reason for Cancel', copy=False, index=True, tracking=3) + attachment_bukti = fields.Many2one( + 'ir.attachment', + string="Attachment Bukti Cancel", readonly=False, + ) + nomor_so_pengganti = fields.Char(string='Nomor SO Pengganti', copy=False, tracking=3) def _compute_shipping_method_picking(self): for order in self: @@ -1085,8 +1142,22 @@ class SaleOrder(models.Model): self.due_id = False if main_parent.use_so_approval: self.send_notif_to_salesperson(cancel=True) + for order in self: + if order.amount_total > 30000000: + return { + 'type': 'ir.actions.act_window', + 'name': _('Cancel Reason'), + 'res_model': 'cancel.reason.order', + 'view_mode': 'form', + 'target': 'new', + 'context': {'default_request_id': self.id}, + } return super(SaleOrder, self).action_cancel() - + + def confirm_cancel_order(self): + """Fungsi ini akan dipanggil oleh wizard setelah alasan pembatalan dipilih""" + return super(SaleOrder, self).action_cancel() + def validate_partner_invoice_due(self): parent_id = self.partner_id.parent_id.id parent_id = parent_id if parent_id else self.partner_id.id -- cgit v1.2.3 From eeff963c94f4d933b89308f40b387fd67ef881c4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 11 Feb 2025 16:18:57 +0700 Subject: fix bug backorder state reserve --- indoteknik_custom/models/stock_picking.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index b1b1bdb8..f49c493c 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -470,6 +470,38 @@ class StockPicking(models.Model): ('state', 'not in', ['cancel', 'draft', 'done']), ('picking_type_code', '=', 'outgoing') ]) + + count = self.search_count([ + ('state', 'not in', ['cancel', 'draft', 'done']), + ('picking_type_code', '=', 'outgoing') + ]) + + for picking in pickings: + fullfillments = self.env['sales.order.fulfillment.v2'].search([ + ('sale_order_id', '=', picking.sale_id.id) + ]) + + picking.state_reserve = 'ready' + picking.date_reserved = picking.date_reserved or datetime.datetime.utcnow() + + if any(rec.so_qty != rec.reserved_stock_qty for rec in fullfillments): + picking.state_reserve = 'waiting' + picking.date_reserved = '' + + self.check_state_reserve_backorder() + + def check_state_reserve_backorder(self): + pickings = self.search([ + ('backorder_id', '!=', False), + ('picking_type_code', '=', 'outgoing'), + ('state', 'not in', ['cancel', 'draft', 'done']) + ]) + + count = self.search_count([ + ('backorder_id', '!=', False), + ('picking_type_code', '=', 'outgoing'), + ('state', 'not in', ['cancel', 'draft', 'done']) + ]) for picking in pickings: fullfillments = self.env['sales.order.fulfillment.v2'].search([ -- cgit v1.2.3 From ee106a0245fe05c3b5341e7c0f2606d7c5adb8de Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 11 Feb 2025 16:40:46 +0700 Subject: add tracking reason reject and reset to draft --- indoteknik_custom/models/user_pengajuan_tempo_request.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index e2c08cb2..4a1994fb 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -55,7 +55,14 @@ class UserPengajuanTempoRequest(models.Model): ('approval_director', 'Approved by Director'), ('reject', 'Rejected'), ], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft') - reason_reject = fields.Char(string='Limit Tempo') + last_state_tempo = fields.Selection([ + ('draft', 'Pengajuan Tempo'), + ('approval_sales', 'Approved by Sales Manager'), + ('approval_finance', 'Approved by Finance'), + ('approval_director', 'Approved by Director'), + ('reject', 'Rejected'), + ], string='Status',) + reason_reject = fields.Char(string='Reason Reaject', tracking=True, track_visibility='onchange') # informasi perusahaan name_tempo = fields.Many2one('res.partner', string='Nama Perusahaan', related='pengajuan_tempo_id.name_tempo', store=True, tracking=True, readonly=False) @@ -409,6 +416,9 @@ class UserPengajuanTempoRequest(models.Model): 'target': 'new', 'context': {'default_request_id': self.id}, } + def button_draft(self): + for tempo in self: + tempo.state_tempo = tempo.last_state_tempo if tempo.last_state_tempo else 'draft' def write(self, vals): is_approve = True if self.state_tempo == 'approval_director' or vals.get('state_tempo') == 'approval_director' else False -- cgit v1.2.3 From 1c42539aeb53207b07bde3030d2316b58c2cf81e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 12 Feb 2025 09:41:59 +0700 Subject: trying to fix bug state reserve --- indoteknik_custom/models/stock_picking.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index f49c493c..49e66786 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -468,7 +468,8 @@ class StockPicking(models.Model): def check_state_reserve(self): pickings = self.search([ ('state', 'not in', ['cancel', 'draft', 'done']), - ('picking_type_code', '=', 'outgoing') + ('picking_type_code', '=', 'outgoing'), + ('name', 'ilike', 'BU/OUT/'), ]) count = self.search_count([ @@ -493,6 +494,7 @@ class StockPicking(models.Model): def check_state_reserve_backorder(self): pickings = self.search([ ('backorder_id', '!=', False), + ('name', 'ilike', 'BU/OUT/'), ('picking_type_code', '=', 'outgoing'), ('state', 'not in', ['cancel', 'draft', 'done']) ]) -- cgit v1.2.3 From 7f284e263de51242459ca780af32fe0e372f7ac4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 12 Feb 2025 15:02:14 +0700 Subject: update code --- indoteknik_custom/models/sale_order.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index b1039750..d0b72ed3 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -37,11 +37,16 @@ class CancelReasonOrder(models.TransientModel): order = self.request_id if order: order.write({'reason_cancel': self.reason_cancel}) + if not self.attachment_bukti: + raise UserError('Attachment bukti wajib disertakan') order.write({'attachment_bukti': self.attachment_bukti}) order.message_post(body='Attachment Bukti Cancel', attachment_ids=[self.attachment_bukti.id]) - if self.nomor_so_pengganti or self.reason_cancel == 'ganti_quotation': - order.write({'nomor_so_pengganti': self.nomor_so_pengganti}) + if self.reason_cancel == 'ganti_quotation': + if self.nomor_so_pengganti: + order.write({'nomor_so_pengganti': self.nomor_so_pengganti}) + else: + raise UserError('Nomor SO pengganti wajib disertakan') order.confirm_cancel_order() return {'type': 'ir.actions.act_window_close'} -- cgit v1.2.3 From 3a53992e940724ccb1fbd72329c2db810b8fc83d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 13 Feb 2025 10:43:29 +0700 Subject: fix delete create company when reject company request --- indoteknik_custom/models/user_company_request.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index af8a86ba..9216e8eb 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -104,9 +104,9 @@ class UserCompanyRequest(models.Model): self.user_company_id.active = True user.send_company_switch_approve_mail() if vals.get('is_switch_account') == True else user.send_company_request_approve_mail() else: - new_company = self.env['res.partner'].create({ - 'name': self.user_input - }) + # new_company = self.env['res.partner'].create({ + # 'name': self.user_input + # }) # self.user_id.parent_id = new_company.id user.send_company_request_reject_mail() return super(UserCompanyRequest, self).write(vals) -- cgit v1.2.3 From 3474af21127db27f1b63ddb879e26da232e2e3d0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 13 Feb 2025 11:05:51 +0700 Subject: cr get validate purchase price --- indoteknik_custom/models/sale_order_line.py | 36 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index aed95aab..abf10f42 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -159,7 +159,7 @@ class SaleOrderLine(models.Model): # [('vendor_id', '=', self.product_id.x_manufacture.override_vendor_id.id), # ('product_id', '=', self.product_id.id)], # limit=1, order='count_trx_po desc, count_trx_po_vendor desc') - price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) + price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id, manual=True) self.purchase_price = price self.purchase_tax_id = taxes # else: @@ -205,37 +205,46 @@ class SaleOrderLine(models.Model): def _get_purchase_price(self, product_id): purchase_price = self.env['purchase.pricelist'].search( [('product_id', '=', product_id.id), - ('is_winner', '=', True)], + # ('is_winner', '=', True) + ], limit=1) + + vendor_id = purchase_price.brand_id.override_vendor_id + if vendor_id: + return self._get_purchase_price_by_vendor(product_id, vendor_id) + return self._get_valid_purchase_price(purchase_price) - def _get_purchase_price_by_vendor(self, product_id, vendor_id): + def _get_purchase_price_by_vendor(self, product_id, vendor_id, manual=False): purchase_price = self.env['purchase.pricelist'].search( [('product_id', '=', product_id.id), - ('vendor_id', '=', vendor_id.id), - # ('is_winner', '=', True) - ], - limit=1) + ('vendor_id', '=', vendor_id.id)], + limit=1 + ) + + if purchase_price: + return self._get_valid_purchase_price(purchase_price, manual) + + # Return default values when no purchase_price is found + return 0, '', None # Ensure 3 values are always returned - return self._get_valid_purchase_price(purchase_price) - def _get_valid_purchase_price(self, purchase_price): + def _get_valid_purchase_price(self, purchase_price, manual): current_time = datetime.now() delta_time = current_time - timedelta(days=365) # delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') price = 0 taxes = '' - vendor_id = '' + vendor_id = purchase_price.vendor_id.id or '' human_last_update = purchase_price.human_last_update or datetime.min system_last_update = purchase_price.system_last_update or datetime.min if purchase_price.taxes_product_id.type_tax_use == 'purchase': price = purchase_price.product_price taxes = purchase_price.taxes_product_id.id - vendor_id = purchase_price.vendor_id.id - if delta_time > human_last_update: + if delta_time > human_last_update or (not purchase_price.brand_id.override_vendor_id and manual == False): price = 0 taxes = '' vendor_id = '' @@ -244,8 +253,7 @@ class SaleOrderLine(models.Model): if purchase_price.taxes_system_id.type_tax_use == 'purchase': price = purchase_price.system_price taxes = purchase_price.taxes_system_id.id - vendor_id = purchase_price.vendor_id.id - if delta_time > system_last_update: + if delta_time > human_last_update or (not purchase_price.brand_id.override_vendor_id and manual == False): price = 0 taxes = '' vendor_id = '' -- cgit v1.2.3 From dce36bb896e89a763b182924b0cfa9cec4f39735 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 13 Feb 2025 12:34:21 +0700 Subject: fix bug --- indoteknik_custom/models/sale_order_line.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index abf10f42..af521c2c 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -202,19 +202,19 @@ class SaleOrderLine(models.Model): # self.price_unit = selling_price # self.tax_id = tax_id - def _get_purchase_price(self, product_id): + def _get_purchase_price(self, product_id, manual=False): purchase_price = self.env['purchase.pricelist'].search( - [('product_id', '=', product_id.id), - # ('is_winner', '=', True) - ], - limit=1) + [('product_id', '=', product_id.id)], + limit=1 + ) vendor_id = purchase_price.brand_id.override_vendor_id if vendor_id: - return self._get_purchase_price_by_vendor(product_id, vendor_id) - - return self._get_valid_purchase_price(purchase_price) + return self._get_purchase_price_by_vendor(product_id, vendor_id, manual) + + return self._get_valid_purchase_price(purchase_price, manual) + def _get_purchase_price_by_vendor(self, product_id, vendor_id, manual=False): purchase_price = self.env['purchase.pricelist'].search( -- cgit v1.2.3 From 78a7df26d09b64fb9b3b45084212cbf19c1907a1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 13 Feb 2025 13:51:36 +0700 Subject: returns the code to the beginning --- indoteknik_custom/models/sale_order_line.py | 44 ++++++++++++----------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index af521c2c..aed95aab 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -159,7 +159,7 @@ class SaleOrderLine(models.Model): # [('vendor_id', '=', self.product_id.x_manufacture.override_vendor_id.id), # ('product_id', '=', self.product_id.id)], # limit=1, order='count_trx_po desc, count_trx_po_vendor desc') - price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id, manual=True) + price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) self.purchase_price = price self.purchase_tax_id = taxes # else: @@ -202,49 +202,40 @@ class SaleOrderLine(models.Model): # self.price_unit = selling_price # self.tax_id = tax_id - def _get_purchase_price(self, product_id, manual=False): + def _get_purchase_price(self, product_id): purchase_price = self.env['purchase.pricelist'].search( - [('product_id', '=', product_id.id)], - limit=1 - ) - - vendor_id = purchase_price.brand_id.override_vendor_id - - if vendor_id: - return self._get_purchase_price_by_vendor(product_id, vendor_id, manual) - - return self._get_valid_purchase_price(purchase_price, manual) + [('product_id', '=', product_id.id), + ('is_winner', '=', True)], + limit=1) + return self._get_valid_purchase_price(purchase_price) - def _get_purchase_price_by_vendor(self, product_id, vendor_id, manual=False): + def _get_purchase_price_by_vendor(self, product_id, vendor_id): purchase_price = self.env['purchase.pricelist'].search( [('product_id', '=', product_id.id), - ('vendor_id', '=', vendor_id.id)], - limit=1 - ) - - if purchase_price: - return self._get_valid_purchase_price(purchase_price, manual) - - # Return default values when no purchase_price is found - return 0, '', None # Ensure 3 values are always returned + ('vendor_id', '=', vendor_id.id), + # ('is_winner', '=', True) + ], + limit=1) + return self._get_valid_purchase_price(purchase_price) - def _get_valid_purchase_price(self, purchase_price, manual): + def _get_valid_purchase_price(self, purchase_price): current_time = datetime.now() delta_time = current_time - timedelta(days=365) # delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') price = 0 taxes = '' - vendor_id = purchase_price.vendor_id.id or '' + vendor_id = '' human_last_update = purchase_price.human_last_update or datetime.min system_last_update = purchase_price.system_last_update or datetime.min if purchase_price.taxes_product_id.type_tax_use == 'purchase': price = purchase_price.product_price taxes = purchase_price.taxes_product_id.id - if delta_time > human_last_update or (not purchase_price.brand_id.override_vendor_id and manual == False): + vendor_id = purchase_price.vendor_id.id + if delta_time > human_last_update: price = 0 taxes = '' vendor_id = '' @@ -253,7 +244,8 @@ class SaleOrderLine(models.Model): if purchase_price.taxes_system_id.type_tax_use == 'purchase': price = purchase_price.system_price taxes = purchase_price.taxes_system_id.id - if delta_time > human_last_update or (not purchase_price.brand_id.override_vendor_id and manual == False): + vendor_id = purchase_price.vendor_id.id + if delta_time > system_last_update: price = 0 taxes = '' vendor_id = '' -- cgit v1.2.3 From 9bd46f112fdfb4fb7f56866b4e260efbd26c6daa Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 17 Feb 2025 08:36:01 +0700 Subject: renca req tempo status --- indoteknik_custom/models/user_pengajuan_tempo_request.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 4a1994fb..be4293a0 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -63,6 +63,19 @@ class UserPengajuanTempoRequest(models.Model): ('reject', 'Rejected'), ], string='Status',) reason_reject = fields.Char(string='Reason Reaject', tracking=True, track_visibility='onchange') + state_tempo_text = fields.Char(string="Status", compute="_compute_state_tempo_text") + + @api.depends('state_tempo') + def _compute_state_tempo_text(self): + for record in self: + status_mapping = { + 'draft': "Menunggu Approve Manager", + 'approval_sales': "Menunggu Approve Finance", + 'approval_finance': "Menunggu Approve Direktur", + 'approval_director': "Approved", + 'reject': "Rejected", + } + record.state_tempo_text = status_mapping.get(record.state_tempo, "Unknown") # informasi perusahaan name_tempo = fields.Many2one('res.partner', string='Nama Perusahaan', related='pengajuan_tempo_id.name_tempo', store=True, tracking=True, readonly=False) -- cgit v1.2.3 From b2f39b75e96ef7c80f32ddd7cec86de1eb6c7279 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 17 Feb 2025 08:54:23 +0700 Subject: add logic if cbd not validasi limit --- indoteknik_custom/models/sale_order.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 9631fe6e..8a851a69 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -942,6 +942,7 @@ class SaleOrder(models.Model): # Ambil blocking stage dari partner block_stage = rec.partner_id.parent_id.blocking_stage if rec.partner_id.parent_id else rec.partner_id.blocking_stage or 0 + is_cbd = rec.partner_id.parent_id.property_payment_term_id.id == 26 if rec.partner_id.parent_id else rec.partner_id.property_payment_term_id.id == 26 or False # Ambil jumlah nilai dari SO yang invoice_status masih 'to invoice' so_to_invoice = 0 @@ -952,7 +953,7 @@ class SaleOrder(models.Model): remaining_credit_limit = block_stage - current_total - so_to_invoice # Validasi limit - if remaining_credit_limit <= 0 and block_stage > 0: + if remaining_credit_limit <= 0 and block_stage > 0 and not is_cbd: raise UserError(_("The credit limit for %s will exceed the Blocking Stage if the Sale Order is confirmed. The remaining credit limit is %s, from %s and the outstanding amount is %s.") % (rec.partner_id.name, block_stage - current_total, block_stage, outstanding_amount)) -- cgit v1.2.3 From 5f14f6eb9256a7bbdbab8b5ba5482939a479f59a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 18 Feb 2025 08:27:26 +0700 Subject: CR back margin leader approval to 13% --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 8a851a69..24b1d85c 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1119,7 +1119,7 @@ class SaleOrder(models.Model): return False def _requires_approval_margin_leader(self): - return self.total_percent_margin <= 13 and not self.env.user.is_leader + return self.total_percent_margin <= 15 and not self.env.user.is_leader def _requires_approval_margin_manager(self): return self.total_percent_margin <= 20 and not self.env.user.is_leader and not self.env.user.is_sales_manager -- cgit v1.2.3 From cbe7af2817b0a18097ace08e63e32e02d7ce4c26 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 18 Feb 2025 09:16:09 +0700 Subject: CR margin approve leader jadi < 15% not <= 15 --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 24b1d85c..430b4526 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1119,7 +1119,7 @@ class SaleOrder(models.Model): return False def _requires_approval_margin_leader(self): - return self.total_percent_margin <= 15 and not self.env.user.is_leader + return self.total_percent_margin < 15 and not self.env.user.is_leader def _requires_approval_margin_manager(self): return self.total_percent_margin <= 20 and not self.env.user.is_leader and not self.env.user.is_sales_manager -- cgit v1.2.3 From 80c56615d5c605f6e96cc3567a6b3d0332152957 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 18 Feb 2025 13:16:20 +0700 Subject: CR customer commision --- indoteknik_custom/models/commision.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 48f1c7f6..3f035e2f 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -153,6 +153,10 @@ class CustomerCommision(models.Model): bank_account = fields.Char(string='Account No', tracking=3) note_transfer = fields.Char(string='Keterangan') brand_ids = fields.Many2many('x_manufactures', string='Brands') + payment_status = fields.Selection([ + ('pending', 'Pending'), + ('payment', 'Payment'), + ], string='Payment Status', copy=False, readonly=True, tracking=3, default='pending') # add status for type of commision, fee, rebate / cashback # include child or not? @@ -228,6 +232,15 @@ class CustomerCommision(models.Model): raise UserError('Harus di approved oleh yang bersangkutan') return + def action_confirm_customer_payment(self): + group_id = self.env.ref('indoteknik_custom.group_role_fat').id + users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + if self.env.user.id not in users_in_group.mapped('id'): + raise UserError('Hanya bisa dikonfirmasi oleh FAT') + else: + self.payment_status = 'payment' + return + def generate_customer_commision(self): if self.commision_lines: raise UserError('Line sudah ada, tidak bisa di generate ulang') -- cgit v1.2.3 From a9abc6b63f1bafb1e007da4446636ec2da10d493 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 18 Feb 2025 13:19:43 +0700 Subject: back to original before CR customer commision --- indoteknik_custom/models/commision.py | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 3f035e2f..48f1c7f6 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -153,10 +153,6 @@ class CustomerCommision(models.Model): bank_account = fields.Char(string='Account No', tracking=3) note_transfer = fields.Char(string='Keterangan') brand_ids = fields.Many2many('x_manufactures', string='Brands') - payment_status = fields.Selection([ - ('pending', 'Pending'), - ('payment', 'Payment'), - ], string='Payment Status', copy=False, readonly=True, tracking=3, default='pending') # add status for type of commision, fee, rebate / cashback # include child or not? @@ -232,15 +228,6 @@ class CustomerCommision(models.Model): raise UserError('Harus di approved oleh yang bersangkutan') return - def action_confirm_customer_payment(self): - group_id = self.env.ref('indoteknik_custom.group_role_fat').id - users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - if self.env.user.id not in users_in_group.mapped('id'): - raise UserError('Hanya bisa dikonfirmasi oleh FAT') - else: - self.payment_status = 'payment' - return - def generate_customer_commision(self): if self.commision_lines: raise UserError('Line sudah ada, tidak bisa di generate ulang') -- cgit v1.2.3 From 10c0cd096353397ce26ad13b6967a35d13072fb6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:39:25 +0700 Subject: label in move line same with ref in entries --- indoteknik_custom/models/account_move_line.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 37f7c77c..31950f4c 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -23,3 +23,11 @@ class AccountMoveLine(models.Model): else: account.is_required = False + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'move_id' in vals: + move = self.env['account.move'].browse(vals['move_id']) + if move.move_type == 'entry': + vals['name'] = move.ref + return super().create(vals_list) \ No newline at end of file -- cgit v1.2.3 From 45f6f270ae76b5e2d811f4ef04e9b64ba5b7f143 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:41:06 +0700 Subject: fix error --- indoteknik_custom/models/account_move_line.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 31950f4c..6b394da3 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -24,10 +24,10 @@ class AccountMoveLine(models.Model): account.is_required = False @api.model_create_multi - def create(self, vals_list): - for vals in vals_list: - if 'move_id' in vals: - move = self.env['account.move'].browse(vals['move_id']) - if move.move_type == 'entry': - vals['name'] = move.ref - return super().create(vals_list) \ No newline at end of file + def create(self, vals_list): + for vals in vals_list: + if 'move_id' in vals: + move = self.env['account.move'].browse(vals['move_id']) + if move.move_type == 'entry': + vals['name'] = move.ref + return super().create(vals_list) \ No newline at end of file -- cgit v1.2.3 From bf61388fb16a59dcf954cd288c830f00c62efee5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:42:12 +0700 Subject: fix error --- indoteknik_custom/models/account_move_line.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 6b394da3..a4386157 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -21,13 +21,4 @@ class AccountMoveLine(models.Model): if account.account_id.code and account.account_id.code[0] in ['6', '7']: account.is_required = True else: - account.is_required = False - - @api.model_create_multi - def create(self, vals_list): - for vals in vals_list: - if 'move_id' in vals: - move = self.env['account.move'].browse(vals['move_id']) - if move.move_type == 'entry': - vals['name'] = move.ref - return super().create(vals_list) \ No newline at end of file + account.is_required = False \ No newline at end of file -- cgit v1.2.3 From 62636c80dcc2078eed18810e7958f41fd5b13fdc Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 09:42:39 +0700 Subject: fix error --- indoteknik_custom/models/account_move_line.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index a4386157..6b394da3 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -21,4 +21,13 @@ class AccountMoveLine(models.Model): if account.account_id.code and account.account_id.code[0] in ['6', '7']: account.is_required = True else: - account.is_required = False \ No newline at end of file + account.is_required = False + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'move_id' in vals: + move = self.env['account.move'].browse(vals['move_id']) + if move.move_type == 'entry': + vals['name'] = move.ref + return super().create(vals_list) \ No newline at end of file -- cgit v1.2.3 From 66901cd03a1494e6c84893e14083dcd1fbe737a5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 19 Feb 2025 14:01:44 +0700 Subject: fix bug account move --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/account_move.py | 3 +- indoteknik_custom/models/account_move_line.py | 2 +- .../models/account_payment_register.py | 48 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/models/account_payment_register.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index ddbe16f1..dea3eeea 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -142,3 +142,4 @@ from . import stock_immediate_transfer from . import coretax_fatur from . import ir_actions_report from . import barcoding_product +from . import account_payment_register diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 7760c69d..b2ac47c2 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -64,6 +64,7 @@ class AccountMove(models.Model): nomor_kwitansi = fields.Char(string="Nomor Kwitansi") other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal') other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes') + is_hr = fields.Boolean(string="Is HR?", default=False) def _update_line_name_from_ref(self): """Update all account.move.line name fields with ref from account.move""" @@ -114,7 +115,7 @@ class AccountMove(models.Model): def create(self, vals): vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' result = super(AccountMove, self).create(vals) - result._update_line_name_from_ref() + # result._update_line_name_from_ref() return result def compute_so_shipping_paid_by(self): diff --git a/indoteknik_custom/models/account_move_line.py b/indoteknik_custom/models/account_move_line.py index 6b394da3..7c95d4ef 100644 --- a/indoteknik_custom/models/account_move_line.py +++ b/indoteknik_custom/models/account_move_line.py @@ -28,6 +28,6 @@ class AccountMoveLine(models.Model): for vals in vals_list: if 'move_id' in vals: move = self.env['account.move'].browse(vals['move_id']) - if move.move_type == 'entry': + if move.move_type == 'entry' and move.is_hr == True: vals['name'] = move.ref return super().create(vals_list) \ No newline at end of file diff --git a/indoteknik_custom/models/account_payment_register.py b/indoteknik_custom/models/account_payment_register.py new file mode 100644 index 00000000..4ebb7e4e --- /dev/null +++ b/indoteknik_custom/models/account_payment_register.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError + + +class AccountPaymentRegister(models.TransientModel): + _inherit = 'account.payment.register' + def _create_payment_vals_from_wizard(self): + payment_vals = { + 'date': self.payment_date, + 'amount': self.amount, + 'payment_type': self.payment_type, + 'partner_type': self.partner_type, + 'ref': self.communication, + 'journal_id': self.journal_id.id, + 'is_hr': True, + 'currency_id': self.currency_id.id, + 'partner_id': self.partner_id.id, + 'partner_bank_id': self.partner_bank_id.id, + 'payment_method_id': self.payment_method_id.id, + 'destination_account_id': self.line_ids[0].account_id.id + } + + if not self.currency_id.is_zero(self.payment_difference) and self.payment_difference_handling == 'reconcile': + payment_vals['write_off_line_vals'] = { + 'name': self.writeoff_label, + 'amount': self.payment_difference, + 'account_id': self.writeoff_account_id.id, + } + return payment_vals + + def _create_payment_vals_from_batch(self, batch_result): + batch_values = self._get_wizard_values_from_batch(batch_result) + return { + 'date': self.payment_date, + 'amount': batch_values['source_amount_currency'], + 'payment_type': batch_values['payment_type'], + 'partner_type': batch_values['partner_type'], + 'ref': self._get_batch_communication(batch_result), + 'journal_id': self.journal_id.id, + 'is_hr': True, + 'currency_id': batch_values['source_currency_id'], + 'partner_id': batch_values['partner_id'], + 'partner_bank_id': batch_result['key_values']['partner_bank_id'], + 'payment_method_id': self.payment_method_id.id, + 'destination_account_id': batch_result['lines'][0].account_id.id + } -- cgit v1.2.3 From b7580b1590fc3259aa028c0c909b0ee564e801d5 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 19 Feb 2025 14:49:40 +0700 Subject: update customer --- indoteknik_custom/models/commision.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 3f035e2f..03473b09 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -233,6 +233,8 @@ class CustomerCommision(models.Model): return def action_confirm_customer_payment(self): + if self.payment_status == 'payment': + raise UserError('Customer Commision sudah berstatus Payment') group_id = self.env.ref('indoteknik_custom.group_role_fat').id users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) if self.env.user.id not in users_in_group.mapped('id'): -- cgit v1.2.3 From 38f8ddd9aaaad58c8d7ea27235cd109ba288693d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 19 Feb 2025 15:02:35 +0700 Subject: change logic solr is_in_bu from available to qty_free_bandengan --- indoteknik_custom/models/solr/product_template.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 87e8370f..8afff6e3 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -76,8 +76,11 @@ class ProductTemplate(models.Model): ('product_id', 'in', template.product_variant_ids.ids), ('location_id', 'in', target_locations), ]) - - is_in_bu = any(quant.available_quantity > 0 for quant in stock_quant) + is_in_bu = False + for quant in stock_quant: + if quant.product_id.qty_free_bandengan > 0: + is_in_bu = True + break cleaned_desc = BeautifulSoup(template.website_description or '', "html.parser").get_text() website_description = template.website_description if cleaned_desc else '' -- cgit v1.2.3 From 7c1c4def22a72b9a6f6806d70a865594ae14386c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 20 Feb 2025 16:20:25 +0700 Subject: add CR voucher type account --- indoteknik_custom/models/res_users.py | 7 +++++++ indoteknik_custom/models/voucher.py | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 31b84ae3..63942bb5 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -71,6 +71,13 @@ class ResUsers(models.Model): if not vouchers: return None return ', '.join(x.code for x in vouchers) return None + + def get_voucher_code_switch_account(self, type): + if type == 'switch_account': + vouchers = self.env['voucher'].get_active_voucher([('account_type', 'in', ['all','company'])]) + if not vouchers: return None + return ', '.join(x.code for x in vouchers) + return None def check_access(self, model, mode): assert mode in ('read', 'write', 'create', 'unlink', 'import', 'export'), 'Invalid access mode' diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 37c97338..101d4bcf 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -59,7 +59,11 @@ class Voucher(models.Model): show_on_email = fields.Selection([ ('user_activation', 'User Activation') ], 'Show on Email') - + account_type = fields.Selection(string='Account Type', default="all", selection=[ + ('all', "All Account"), + ('person', "Account Individu"), + ('company', "Account Company"), + ]) @api.constrains('description') def _check_description_length(self): for record in self: -- cgit v1.2.3 From 093bd33ba36ba123a53853e7407e534f9f23734b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 21 Feb 2025 10:21:34 +0700 Subject: add voucher info in email approve switch account --- indoteknik_custom/models/res_users.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 63942bb5..b0864f2c 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -70,11 +70,8 @@ class ResUsers(models.Model): vouchers = self.env['voucher'].get_active_voucher([('show_on_email', '=', 'user_activation')]) if not vouchers: return None return ', '.join(x.code for x in vouchers) - return None - - def get_voucher_code_switch_account(self, type): if type == 'switch_account': - vouchers = self.env['voucher'].get_active_voucher([('account_type', 'in', ['all','company'])]) + vouchers = self.env['voucher'].get_active_voucher([('excl_pricelist_ids', 'not in', [1]), ('apply_type', 'in', ['all', 'brand']), ('account_type', 'in', ['all', 'company']), ('visibility', 'in', ['public'])]) if not vouchers: return None return ', '.join(x.code for x in vouchers) return None -- cgit v1.2.3 From 8696e202ecf594890a9ad29bc2bd2729321459c5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 24 Feb 2025 14:58:11 +0700 Subject: add copy to field state_reserve and date_reserved --- indoteknik_custom/models/stock_picking.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 49e66786..954a5d52 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -94,7 +94,7 @@ class StockPicking(models.Model): purchase_representative_id = fields.Many2one('res.users', related='move_lines.purchase_line_id.order_id.user_id', string="Purchase Representative") carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method') shipping_status = fields.Char(string='Shipping Status', compute="_compute_shipping_status") - date_reserved = fields.Datetime(string="Date Reserved", help='Tanggal ter-reserved semua barang nya') + date_reserved = fields.Datetime(string="Date Reserved", help='Tanggal ter-reserved semua barang nya', copy=False) status_printed = fields.Selection([ ('not_printed', 'Belum Print'), ('printed', 'Printed') @@ -120,7 +120,7 @@ class StockPicking(models.Model): ('ready', 'Ready to Ship'), ('done', 'Done'), ('cancel', 'Cancelled'), - ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.") + ], string='Status Reserve', readonly=True, tracking=True, copy=False, help="The current state of the stock picking.") notee = fields.Text(string="Note") @api.model -- cgit v1.2.3 From b20368190fbf08b87d8a665c4b316786e3d73141 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 24 Feb 2025 15:36:22 +0700 Subject: state reserve --- indoteknik_custom/models/stock_picking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 954a5d52..36d9f63d 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -120,7 +120,7 @@ class StockPicking(models.Model): ('ready', 'Ready to Ship'), ('done', 'Done'), ('cancel', 'Cancelled'), - ], string='Status Reserve', readonly=True, tracking=True, copy=False, help="The current state of the stock picking.") + ], string='Status Reserve', tracking=True, copy=False, help="The current state of the stock picking.") notee = fields.Text(string="Note") @api.model -- cgit v1.2.3 From 63c712cd38666723a112899d49af3ee82af9bf89 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 24 Feb 2025 16:04:59 +0700 Subject: adjusment number --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/stock_inventory.py | 59 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 indoteknik_custom/models/stock_inventory.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index dea3eeea..f33a7411 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -143,3 +143,4 @@ from . import coretax_fatur from . import ir_actions_report from . import barcoding_product from . import account_payment_register +from . import stock_inventory diff --git a/indoteknik_custom/models/stock_inventory.py b/indoteknik_custom/models/stock_inventory.py new file mode 100644 index 00000000..12a891de --- /dev/null +++ b/indoteknik_custom/models/stock_inventory.py @@ -0,0 +1,59 @@ +from odoo import models, api, fields +from odoo.exceptions import UserError +from datetime import datetime +import logging + +_logger = logging.getLogger(__name__) + + +class StockInventory(models.Model): + _inherit = ['stock.inventory'] + _order = 'id desc' + _rec_name = 'number' + + number = fields.Char(string='Document No', index=True, copy=False, readonly=True) + adjusment_type = fields.Selection([ + ('in', 'Adjusment In'), + ('out', 'Adjusment Out'), + ], string='Adjusments Type', required=True) + + def _generate_number_stock_inventory(self): + """Men-generate nomor untuk semua stock inventory yang belum memiliki number.""" + stock_records = self.env['stock.inventory'].search([('number', '=', False)], order='id asc') + for record in stock_records: + self._assign_number(record) + + _logger.info('Generate Number Done') + + def _assign_number(self, record): + """Menentukan nomor berdasarkan kategori Adjust-In atau Adjust-Out.""" + name_upper = record.name.upper() if record.name else "" + + if self.adjusment_type == 'out' or "ADJUST OUT" in name_upper or "ADJUST-OUT" in name_upper or "OUT" in name_upper: + last_number = self._get_last_sequence("ADJUST/OUT/") + record.number = f"ADJUST/OUT/{last_number}" + elif self.adjusment_type == 'in' or "ADJUST IN" in name_upper or "ADJUST-IN" in name_upper or "IN" in name_upper: + last_number = self._get_last_sequence("ADJUST/IN/") + record.number = f"ADJUST/IN/{last_number}" + else: + record.number = "UNKNOWN" # Jika tidak termasuk kategori + + def _get_last_sequence(self, prefix): + """Mengambil nomor terakhir berdasarkan prefix (ADJUST/OUT/ atau ADJUST/IN/) dengan format 00001, 00002, dst.""" + last_record = self.env['stock.inventory'].search( + [("number", "like", f"{prefix}%")], order="number desc", limit=1 + ) + + if last_record and last_record.number: + try: + last_number = int(last_record.number.split("/")[-1]) # Ambil angka terakhir + return str(last_number + 1).zfill(5) # Format jadi 00001, 00002, dst. + except ValueError: + return "00001" # Jika format tidak valid, mulai dari 00001 + return "00001" # Jika belum ada data, mulai dari 00001 + + @api.model + def create(self, vals): + order = super(StockInventory, self).create(vals) + self._assign_number(order) + return order -- cgit v1.2.3 From 6352ba63a39293b3e260bd7bd933c9de2c023172 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 10:47:35 +0700 Subject: add purchase price po and so on po sales matches --- indoteknik_custom/models/purchase_order_sales_match.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index d1d929d3..d6c2a631 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -24,6 +24,13 @@ class PurchaseOrderSalesMatch(models.Model): margin_item = fields.Float(string='Margin') delivery_amt = fields.Float(string='Delivery Amount', compute='_compute_delivery_amt') margin_deduct = fields.Float(string='After Deduct', compute='_compute_delivery_amt') + purchase_price_so = fields.Float(string='Purchase Price Sale Order', related='sale_line_id.purchase_price') + purchase_price_po = fields.Float('Purchase Price PO', compute='_compute_purchase_price_po') + + def _compute_purchase_price_po(self): + for line in self: + purchase_price = self.env['purchase.order.line'].search([('order_id', '=', line.purchase_order_id.id), ('product_id', '=', line.product_id.id)]) + line.purchase_price_po = purchase_price.purchase_price def _compute_delivery_amt(self): for line in self: -- cgit v1.2.3 From f7a149c71824ba40f9e585d1df287b36853b7213 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 10:49:49 +0700 Subject: fix bug --- indoteknik_custom/models/purchase_order_sales_match.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index d6c2a631..4ebe959b 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -30,7 +30,7 @@ class PurchaseOrderSalesMatch(models.Model): def _compute_purchase_price_po(self): for line in self: purchase_price = self.env['purchase.order.line'].search([('order_id', '=', line.purchase_order_id.id), ('product_id', '=', line.product_id.id)]) - line.purchase_price_po = purchase_price.purchase_price + line.purchase_price_po = purchase_price.price_unit def _compute_delivery_amt(self): for line in self: -- cgit v1.2.3 From 787aa90ca730936c93e0afb250285ebc8708ad3a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 25 Feb 2025 11:17:36 +0700 Subject: cr approved margin SO --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 430b4526..e23f39bc 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1122,7 +1122,7 @@ class SaleOrder(models.Model): return self.total_percent_margin < 15 and not self.env.user.is_leader def _requires_approval_margin_manager(self): - return self.total_percent_margin <= 20 and not self.env.user.is_leader and not self.env.user.is_sales_manager + return self.total_percent_margin >= 15 and not self.env.user.is_leader and not self.env.user.is_sales_manager def _create_approval_notification(self, approval_role): title = 'Warning' -- cgit v1.2.3 From 5fc94808e034dac8efeff3367b665dbd6b4f3df2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:26:52 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 70 ++++++++++-------------------- 1 file changed, 24 insertions(+), 46 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 54d771ba..83f86e8e 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -943,63 +943,41 @@ class PurchaseOrder(models.Model): def compute_total_margin_from_apo(self): sum_so_margin = sum_sales_price = sum_margin = 0 - for line in self.order_sales_match_line: - po_line = self.env['purchase.order.line'].search([ - ('product_id', '=', line.product_id.id), - ('order_id', '=', line.purchase_order_id.id) - ], limit=1) - sale_order_line = line.sale_line_id + for line in self.order_line: + sale_order_line = line.so_line_id if not sale_order_line: sale_order_line = self.env['sale.order.line'].search([ ('product_id', '=', line.product_id.id), - ('order_id', '=', line.sale_id.id) + ('order_id', '=', line.so_id.id) ], limit=1, order='price_reduce_taxexcl') - if sale_order_line and po_line: - so_margin = (line.qty_po / line.qty_so) * sale_order_line.item_margin - sum_so_margin += so_margin - - sales_price = sale_order_line.price_reduce_taxexcl * line.qty_po - if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= (sale_order_line.delivery_amt_line / sale_order_line.product_uom_qty) * line.qty_po - if sale_order_line.order_id.fee_third_party > 0: - sales_price -= (sale_order_line.fee_third_party_line / sale_order_line.product_uom_qty) * line.qty_po - sum_sales_price += sales_price - - - purchase_price = po_line.price_subtotal - if po_line.ending_price > 0: - if po_line.taxes_id.id == 22: - ending_price = po_line.ending_price / 1.11 - purchase_price = ending_price - else: - purchase_price = po_line.ending_price - if line.purchase_order_id.delivery_amount > 0: - purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po - if line.purchase_order_id.delivery_amt > 0: - purchase_price += line.purchase_order_id.delivery_amt - real_item_margin = sales_price - purchase_price - sum_margin += real_item_margin - - if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: - self.total_so_margin = sum_so_margin - self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 - self.total_margin = sum_margin - self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 - - else: - self.total_margin = 0 - self.total_percent_margin = 0 - self.total_so_margin = 0 - self.total_so_percent_margin = 0 - + sum_so_margin += sale_order_line.item_margin + sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty + if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': + sales_price -= sale_order_line.delivery_amt_line + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= sale_order_line.fee_third_party_line + sum_sales_price += sales_price + purchase_price = line.price_subtotal + if line.ending_price > 0: + if line.taxes_id.id == 22: + ending_price = line.ending_price / 1.11 + purchase_price = ending_price + else: + purchase_price = line.ending_price + # purchase_price = line.price_subtotal + if line.order_id.delivery_amount > 0: + purchase_price += line.delivery_amt_line + if line.order_id.delivery_amt > 0: + purchase_price += line.order_id.delivery_amt + real_item_margin = sales_price - purchase_price + sum_margin += real_item_margin if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: self.total_so_margin = sum_so_margin self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 self.total_margin = sum_margin self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 - else: self.total_margin = 0 self.total_percent_margin = 0 -- cgit v1.2.3 From ab1ba4b2b482b207a39ae17e43cdac4b1abb72ce Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:38:21 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 83f86e8e..9c05780b 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -959,7 +959,7 @@ class PurchaseOrder(models.Model): sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price purchase_price = line.price_subtotal - if line.ending_price > 0: + if line.order_id.total_delivery_amount > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: ending_price = line.ending_price / 1.11 purchase_price = ending_price -- cgit v1.2.3 From 6eecc5ecd377e6e7b69519294259b8e66cd8e564 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:40:28 +0700 Subject: fix error --- indoteknik_custom/models/purchase_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 9c05780b..faf0955d 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -959,7 +959,7 @@ class PurchaseOrder(models.Model): sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price purchase_price = line.price_subtotal - if line.order_id.total_delivery_amount > 0 and line.order_id.total_cost_service > 0: + if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: ending_price = line.ending_price / 1.11 purchase_price = ending_price -- cgit v1.2.3 From 0f9e8f280cd50ed5af7cbc98253ebf02068d5f24 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 11:59:08 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index faf0955d..6d02038d 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -944,20 +944,21 @@ class PurchaseOrder(models.Model): def compute_total_margin_from_apo(self): sum_so_margin = sum_sales_price = sum_margin = 0 for line in self.order_line: - sale_order_line = line.so_line_id - if not sale_order_line: - sale_order_line = self.env['sale.order.line'].search([ - ('product_id', '=', line.product_id.id), - ('order_id', '=', line.so_id.id) - ], limit=1, order='price_reduce_taxexcl') - - sum_so_margin += sale_order_line.item_margin - sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty - if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= sale_order_line.delivery_amt_line - if sale_order_line.order_id.fee_third_party > 0: - sales_price -= sale_order_line.fee_third_party_line - sum_sales_price += sales_price + sales_order_line = self.env['purchase.order.sales.match'].search([ + ('product_id', '=', line.product_id.id), + ('order_id', '=', line.so_id.id) + ]) + + for so_line in sales_order_line: + sale_order_line = so_line.sale_line_id + sum_so_margin += sale_order_line.item_margin + sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty + if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': + sales_price -= sale_order_line.delivery_amt_line + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= sale_order_line.fee_third_party_line + sum_sales_price += sales_price + purchase_price = line.price_subtotal if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: -- cgit v1.2.3 From 780a7642c97518a3d7e6cdc5e2516b354f6e9cae Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 12:00:25 +0700 Subject: fix bug --- indoteknik_custom/models/purchase_order.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 6d02038d..71ee61d3 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -946,7 +946,7 @@ class PurchaseOrder(models.Model): for line in self.order_line: sales_order_line = self.env['purchase.order.sales.match'].search([ ('product_id', '=', line.product_id.id), - ('order_id', '=', line.so_id.id) + ('sale_id', '=', line.so_id.id) ]) for so_line in sales_order_line: @@ -958,7 +958,7 @@ class PurchaseOrder(models.Model): if sale_order_line.order_id.fee_third_party > 0: sales_price -= sale_order_line.fee_third_party_line sum_sales_price += sales_price - + purchase_price = line.price_subtotal if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: if line.taxes_id.id == 22: -- cgit v1.2.3 From c36d351e79fb2b3487e391e8075bbdefaf41fbab Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 12:03:32 +0700 Subject: trying to fix bug margin po --- indoteknik_custom/models/purchase_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 71ee61d3..f2401dec 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -946,7 +946,7 @@ class PurchaseOrder(models.Model): for line in self.order_line: sales_order_line = self.env['purchase.order.sales.match'].search([ ('product_id', '=', line.product_id.id), - ('sale_id', '=', line.so_id.id) + ('purchase_order_id', '=', line.order_id.id) ]) for so_line in sales_order_line: -- cgit v1.2.3 From 141bfb3a32e73d5b8557a70867d957d5ed3d485b Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 25 Feb 2025 13:31:31 +0700 Subject: update code --- indoteknik_custom/models/commision.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 03473b09..6920154a 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -233,6 +233,9 @@ class CustomerCommision(models.Model): return def action_confirm_customer_payment(self): + if self.status != 'approved': + raise UserError('Commision harus di approve terlebih dahulu sebelum di konfirmasi pembayarannya') + if self.payment_status == 'payment': raise UserError('Customer Commision sudah berstatus Payment') group_id = self.env.ref('indoteknik_custom.group_role_fat').id -- cgit v1.2.3 From a24d7b2a21ff24e31eef77e2032a861b7eb13e31 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 25 Feb 2025 13:51:45 +0700 Subject: fix bug --- indoteknik_custom/models/purchase_order.py | 71 ++++++++++++++-------- .../models/purchase_order_sales_match.py | 5 ++ 2 files changed, 51 insertions(+), 25 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index f2401dec..54d771ba 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -943,42 +943,63 @@ class PurchaseOrder(models.Model): def compute_total_margin_from_apo(self): sum_so_margin = sum_sales_price = sum_margin = 0 - for line in self.order_line: - sales_order_line = self.env['purchase.order.sales.match'].search([ + for line in self.order_sales_match_line: + po_line = self.env['purchase.order.line'].search([ ('product_id', '=', line.product_id.id), - ('purchase_order_id', '=', line.order_id.id) - ]) - - for so_line in sales_order_line: - sale_order_line = so_line.sale_line_id - sum_so_margin += sale_order_line.item_margin - sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty + ('order_id', '=', line.purchase_order_id.id) + ], limit=1) + sale_order_line = line.sale_line_id + if not sale_order_line: + sale_order_line = self.env['sale.order.line'].search([ + ('product_id', '=', line.product_id.id), + ('order_id', '=', line.sale_id.id) + ], limit=1, order='price_reduce_taxexcl') + + if sale_order_line and po_line: + so_margin = (line.qty_po / line.qty_so) * sale_order_line.item_margin + sum_so_margin += so_margin + + sales_price = sale_order_line.price_reduce_taxexcl * line.qty_po if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= sale_order_line.delivery_amt_line + sales_price -= (sale_order_line.delivery_amt_line / sale_order_line.product_uom_qty) * line.qty_po if sale_order_line.order_id.fee_third_party > 0: - sales_price -= sale_order_line.fee_third_party_line + sales_price -= (sale_order_line.fee_third_party_line / sale_order_line.product_uom_qty) * line.qty_po sum_sales_price += sales_price - purchase_price = line.price_subtotal - if line.order_id.total_delivery_amt > 0 and line.order_id.total_cost_service > 0: - if line.taxes_id.id == 22: - ending_price = line.ending_price / 1.11 - purchase_price = ending_price - else: - purchase_price = line.ending_price - # purchase_price = line.price_subtotal - if line.order_id.delivery_amount > 0: - purchase_price += line.delivery_amt_line - if line.order_id.delivery_amt > 0: - purchase_price += line.order_id.delivery_amt - real_item_margin = sales_price - purchase_price - sum_margin += real_item_margin + + purchase_price = po_line.price_subtotal + if po_line.ending_price > 0: + if po_line.taxes_id.id == 22: + ending_price = po_line.ending_price / 1.11 + purchase_price = ending_price + else: + purchase_price = po_line.ending_price + if line.purchase_order_id.delivery_amount > 0: + purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po + if line.purchase_order_id.delivery_amt > 0: + purchase_price += line.purchase_order_id.delivery_amt + real_item_margin = sales_price - purchase_price + sum_margin += real_item_margin + + if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: + self.total_so_margin = sum_so_margin + self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 + self.total_margin = sum_margin + self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 + + else: + self.total_margin = 0 + self.total_percent_margin = 0 + self.total_so_margin = 0 + self.total_so_percent_margin = 0 + if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0: self.total_so_margin = sum_so_margin self.total_so_percent_margin = round((sum_so_margin / sum_sales_price), 2) * 100 self.total_margin = sum_margin self.total_percent_margin = round((sum_margin / sum_sales_price), 2) * 100 + else: self.total_margin = 0 self.total_percent_margin = 0 diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index 4ebe959b..ed013dd5 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -26,6 +26,11 @@ class PurchaseOrderSalesMatch(models.Model): margin_deduct = fields.Float(string='After Deduct', compute='_compute_delivery_amt') purchase_price_so = fields.Float(string='Purchase Price Sale Order', related='sale_line_id.purchase_price') purchase_price_po = fields.Float('Purchase Price PO', compute='_compute_purchase_price_po') + purchase_line_id = fields.Many2one('purchase.order.line', string='Purchase Line', compute='_compute_purchase_line_id') + + def _compute_purchase_line_id(self): + for line in self: + line.purchase_line_id = self.env['purchase.order.line'].search([('order_id', '=', line.purchase_order_id.id), ('product_id', '=', line.product_id.id)]) def _compute_purchase_price_po(self): for line in self: -- cgit v1.2.3 From c459ff9c8b326929e748bb35b3dffe1cc9248e8a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 26 Feb 2025 13:46:53 +0700 Subject: margin per line on po --- indoteknik_custom/models/purchase_order_line.py | 60 ++++++++++++++++++------- 1 file changed, 44 insertions(+), 16 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 587a09a1..033469b8 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -321,32 +321,60 @@ class PurchaseOrderLine(models.Model): def compute_item_margin(self): sum_so_margin = sum_sales_price = sum_margin = 0 + for line in self: - if not line.product_id or line.product_id.type == 'service' or not self.order_id.sale_order_id: + product = line.product_id + order = line.order_id + + # Skip jika tidak ada product_id, produk adalah service, atau tidak ada purchase order terkait + if not product or product.type == 'service' or not order: line.so_item_margin = 0 line.so_item_percent_margin = 0 line.item_margin = 0 line.item_percent_margin = 0 continue - sale_order_line = self.env['sale.order.line'].search( - [('product_id', '=', line.product_id.id), - ('order_id', '=', line.order_id.sale_order_id.id)], limit=1, order='price_reduce_taxexcl') - line.so_item_margin = sale_order_line.item_margin - line.so_item_percent_margin = sale_order_line.item_percent_margin - sum_so_margin += sale_order_line.item_margin - sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty - if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': - sales_price -= sale_order_line.delivery_amt_line - if sale_order_line.order_id.fee_third_party > 0: - sales_price -= sale_order_line.fee_third_party_line - sum_sales_price += sales_price + + # Cari semua sale.order.line terkait dengan purchase.order melalui tabel purchase.order.sales.match + sales_matches = self.env['purchase.order.sales.match'].search([ + ('purchase_order_id', '=', order.id), + ('product_id', '=', product.id) + ]) + + total_sales_price = total_margin = total_qty_so = 0 + for match in sales_matches: + sale_order_line = match.sale_line_id + + # Hitung harga jual setelah mempertimbangkan biaya tambahan + sales_price = sale_order_line.price_reduce_taxexcl * match.qty_so + if sale_order_line.order_id.shipping_cost_covered == 'indoteknik': + sales_price -= sale_order_line.delivery_amt_line + if sale_order_line.order_id.fee_third_party > 0: + sales_price -= sale_order_line.fee_third_party_line + + total_sales_price += sales_price + total_margin += sale_order_line.item_margin + total_qty_so += match.qty_so + + # Set margin berdasarkan total dari semua sales order yang terkait + line.so_item_margin = total_margin + line.so_item_percent_margin = (total_margin / total_sales_price) * 100 if total_sales_price else 0 + + sum_so_margin += total_margin + sum_sales_price += total_sales_price + + # Hitung harga pembelian dengan mempertimbangkan biaya pengiriman purchase_price = line.price_subtotal - if line.order_id.delivery_amount > 0: + if order.delivery_amount > 0: purchase_price += line.delivery_amt_line - real_item_margin = sales_price - purchase_price - real_item_percent_margin = round((real_item_margin/sales_price), 2) * 100 + + # Hitung margin dan persentase margin + real_item_margin = total_sales_price - purchase_price + real_item_percent_margin = (real_item_margin / total_sales_price) * 100 if total_sales_price else 0 + + # Set nilai margin ke dalam line line.item_margin = real_item_margin line.item_percent_margin = real_item_percent_margin + sum_margin += real_item_margin def compute_delivery_amt_line(self): -- cgit v1.2.3 From 860edce900b22241d5f75e1e4613945c577e1c14 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 27 Feb 2025 15:25:13 +0700 Subject: update code jaga jaga kalau so tidak ter-cancel --- indoteknik_custom/models/sale_order.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index f53041cb..d6b5e848 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1162,6 +1162,8 @@ class SaleOrder(models.Model): def confirm_cancel_order(self): """Fungsi ini akan dipanggil oleh wizard setelah alasan pembatalan dipilih""" + if self.state != 'cancel': + self.state = 'cancel' return super(SaleOrder, self).action_cancel() def validate_partner_invoice_due(self): -- cgit v1.2.3 From 74950ab252b92c23b2b5dc754fa4d86a28052145 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 28 Feb 2025 09:57:52 +0700 Subject: update xml coretax --- indoteknik_custom/models/coretax_fatur.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 706a4f44..fec53779 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -59,6 +59,7 @@ class CoretaxFaktur(models.Model): ET.SubElement(tax_invoice, 'TrxCode').text = '04' ET.SubElement(tax_invoice, 'AddInfo') ET.SubElement(tax_invoice, 'CustomDoc') + ET.SubElement(tax_invoice, 'CustomDocMonthYearCustomDocMonthYear') ET.SubElement(tax_invoice, 'RefDesc').text = invoice.name ET.SubElement(tax_invoice, 'FacilityStamp') ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0742260227086000000000' -- cgit v1.2.3 From d67c586c80d87e7e2f3da703cd04e6680fbd62b7 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 28 Feb 2025 10:47:57 +0700 Subject: update bugs coretax xml --- indoteknik_custom/models/coretax_fatur.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index fec53779..b4bffbd2 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -59,7 +59,7 @@ class CoretaxFaktur(models.Model): ET.SubElement(tax_invoice, 'TrxCode').text = '04' ET.SubElement(tax_invoice, 'AddInfo') ET.SubElement(tax_invoice, 'CustomDoc') - ET.SubElement(tax_invoice, 'CustomDocMonthYearCustomDocMonthYear') + ET.SubElement(tax_invoice, 'CustomDocMonthYear') ET.SubElement(tax_invoice, 'RefDesc').text = invoice.name ET.SubElement(tax_invoice, 'FacilityStamp') ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0742260227086000000000' -- cgit v1.2.3 From 7c675cd5bc9f45d2ebca33a63b7184cbb97f0f2f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 3 Mar 2025 09:16:21 +0700 Subject: CR safa add log note when product detail change --- indoteknik_custom/models/requisition.py | 42 ++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index c972b485..1d350929 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -276,10 +276,11 @@ class RequisitionLine(models.Model): _name = 'requisition.line' _description = 'Requisition Line' _order = 'requisition_id, id' + _inherit = ['mail.thread'] requisition_id = fields.Many2one('requisition', string='Ref', required=True, ondelete='cascade', index=True, copy=False) brand_id = fields.Many2one('x_manufactures', string='Brand') - product_id = fields.Many2one('product.product', string='Product') + product_id = fields.Many2one('product.product', string='Product', tracking=3,) partner_id = fields.Many2one('res.partner', string='Vendor') qty_purchase = fields.Float(string='Qty Purchase') price_unit = fields.Float(string='Price') @@ -331,6 +332,45 @@ class RequisitionLine(models.Model): line.taxes_id = taxes line.partner_id = purchase_pricelist.vendor_id.id + @api.model + def create(self, vals): + record = super(RequisitionLine, self).create(vals) + record._track_changes('Tambah') + return record + + def write(self, vals): + for record in self: + old_values = {field: record[field] for field in vals if field in record} + + result = super(RequisitionLine, self).write(vals) + + for record in self: + record._track_changes('Updated', old_values) + + return result + + def unlink(self): + for record in self: + record._track_changes('Hapus') + return super(RequisitionLine, self).unlink() + + def _track_changes(self, action, old_values=None): + message = f"Produk telah di-{action} :
" + if action == 'Tambah': + # message += f"
Product: {self.product_id.name}" + message += f"Product: {self.product_id.name}
Vendor: {self.partner_id.name}
Qty: {self.qty_purchase}
Price: {self.price_unit}
Tax: {self.tax_id.name}
Subtotal: {self.subtotal}
Brand: {self.brand_id.x_name}" + elif action == 'Hapus': + # message += f"
Deleted Product: {self.product_id.name}" + message += f"
Deleted Product: {self.product_id.name}
Vendor: {self.partner_id.name} Qty: {self.qty_purchase}
Price: {self.price_unit}
Tax: {self.tax_id.name}
Subtotal: {self.subtotal}
Brand: {self.brand_id.x_name}" + else: # Updated + for field, old_value in old_values.items(): + new_value = self[field] + if old_value != new_value: + field_label = self._fields[field].string # Ambil nama label field + message += f"{field_label}: {old_value} -> {new_value}
" + + if self.requisition_id: + self.requisition_id.message_post(body=message) class RequisitionPurchaseMatch(models.Model): _name = 'requisition.purchase.match' -- cgit v1.2.3 From cc170c5420fd8854303a63dba59065ab0f87c94e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 4 Mar 2025 10:00:53 +0700 Subject: multi ask approval po and source document bills --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/account_move.py | 1 + indoteknik_custom/models/purchase_order.py | 17 +++++++++++++++++ .../models/purchase_order_multi_ask_approval.py | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 indoteknik_custom/models/purchase_order_multi_ask_approval.py (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index f33a7411..3573eddd 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -106,6 +106,7 @@ from . import sale_monitoring_detail_v2 from . import purchase_order_multi_update from . import invoice_reklas_penjualan from . import purchase_order_multi_confirm +from . import purchase_order_multi_ask_approval from . import po_multi_cancel from . import logbook_sj from . import report_logbook_sj diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index b2ac47c2..9aa0743b 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -65,6 +65,7 @@ class AccountMove(models.Model): other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal') other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes') is_hr = fields.Boolean(string="Is HR?", default=False) + purchase_order_id = fields.Many2one('purchase.order', string='Purchase Order') def _update_line_name_from_ref(self): """Update all account.move.line name fields with ref from account.move""" diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 54d771ba..d90c4a8a 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -155,6 +155,7 @@ class PurchaseOrder(models.Model): 'invoice_date': current_date, 'date': current_date, 'invoice_origin': self.name, + 'purchase_order_id': self.id, 'move_type': 'in_invoice' } @@ -231,6 +232,7 @@ class PurchaseOrder(models.Model): 'invoice_date': current_date, 'date': current_date, 'invoice_origin': self.name, + 'purchase_order_id': self.id, 'move_type': 'in_invoice' } @@ -307,6 +309,7 @@ class PurchaseOrder(models.Model): invoice_vals = { 'ref': self.partner_ref or '', 'move_type': move_type, + 'purchase_order_id': self.id, 'narration': self.notes, 'currency_id': self.currency_id.id, 'invoice_user_id': self.user_id and self.user_id.id or self.env.user.id, @@ -388,6 +391,13 @@ class PurchaseOrder(models.Model): } return action + def open_form_multi_ask_approval_po(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_ask_approval') + action['context'] = { + 'po_ids': [x.id for x in self] + } + return action + def open_form_multi_create_uang_muka(self): action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_uangmuka') action['context'] = { @@ -415,6 +425,13 @@ class PurchaseOrder(models.Model): purchase.button_confirm() + def action_multi_ask_approval_po(self): + for purchase in self: + if purchase.state != 'draft': + continue + + purchase.po_approve() + def open_form_multi_update_paid_status(self): action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_update') action['context'] = { diff --git a/indoteknik_custom/models/purchase_order_multi_ask_approval.py b/indoteknik_custom/models/purchase_order_multi_ask_approval.py new file mode 100644 index 00000000..69f8e5a8 --- /dev/null +++ b/indoteknik_custom/models/purchase_order_multi_ask_approval.py @@ -0,0 +1,22 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class PurchaseOrderMultiUpdate(models.TransientModel): + _name = 'purchase.order.multi_ask_approval' + + def save_multi_ask_approval_po(self): + po_ids = self._context['po_ids'] + purchase = self.env['purchase.order'].browse(po_ids) + purchase.action_multi_ask_approval_po() + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'PO berhasil di ask_approval', + 'next': {'type': 'ir.actions.act_window_close'}, + } + } \ No newline at end of file -- cgit v1.2.3 From 92b6da28414fed56732f86e1f04ea2fac3464d7d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 4 Mar 2025 13:26:28 +0700 Subject: add reason cancel quotation --- indoteknik_custom/models/sale_order.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index d6b5e848..8a983479 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -25,6 +25,7 @@ class CancelReasonOrder(models.TransientModel): ('dokumen_tidak_support', 'Indoteknik tidak bisa support document yang dibutuhkan (Ex: TKDN, COO, SNI)'), ('ganti_quotation', 'Ganti Quotation'), ('testing_internal', 'Testing Internal'), + ('revisi_data', 'Revisi Data'), ], string='Reason for Cancel', required=True, copy=False, index=True, tracking=3) attachment_bukti = fields.Many2many( 'ir.attachment', -- cgit v1.2.3