From 90507e2460b013309483906cff41e02576d5c31b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 30 Nov 2023 14:33:36 +0700 Subject: get attribute from wati --- indoteknik_custom/models/wati.py | 108 ++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index aa63fe92..00b46360 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -101,47 +101,10 @@ class WatiNotification(models.Model): current_time = date_wati delta_time = current_time + timedelta(days=1) new_header.expired_date = delta_time - if not new_header.perusahaan or not new_header.email: - self._get_attribute_wati(new_header) - return - - def _get_attribute_wati(self, new_header): - # url = 'https://live-server-2106.wati.io/api/v1/getContacts' - - # cookies = { - # 'affinity': '1701232090.884.1520.321410|ff187ffce9bc0bae13542bb446e41008', - # } - - # headers = { - # 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3MGM5ZmJhNy00MWRlLTRkMWEtYjY2NS1hM2Q5ODc2ZjhlZWIiLCJ1bmlxdWVfbmFtZSI6InR5YXNAaW5kb3Rla25pay5jb20iLCJuYW1laWQiOiJ0eWFzQGluZG90ZWtuaWsuY29tIiwiZW1haWwiOiJ0eWFzQGluZG90ZWtuaWsuY29tIiwiYXV0aF90aW1lIjoiMTEvMjkvMjAyMyAwNDoxNzo0NyIsImRiX25hbWUiOiIyMTA2IiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiQURNSU5JU1RSQVRPUiIsImV4cCI6MjUzNDAyMzAwODAwLCJpc3MiOiJDbGFyZV9BSSIsImF1ZCI6IkNsYXJlX0FJIn0.--KHv4GCOG2MM3lNW9Nm-0-d8OAVpn5kbcSX4JKqATQ', - # # 'Cookie': 'affinity=1701232090.884.1520.321410|ff187ffce9bc0bae13542bb446e41008', - # } - - # files = { - # 'pageSize': (None, '1'), - # 'pageNumber': (None, '1'), - # 'name': (None, ''), - # 'attribute': (None, '[{name: "phone", operator: "contain", value: "6285751430014"}]'), - # 'createdDate': (None, ''), - # } - - # response = requests.get(url, cookies=cookies, headers=headers, files=files) - # print(response.json()) - wati_api = self.env['wati.api'] - params = { - 'pageSize':1, - 'pageNumber':1, - 'attribute':[{'name': "phone", 'operator': "contain", 'value': "6285751430014"}], - } - wati_contacts = wati_api.http_get('/api/v1/getContacts', params) - if wati_contacts['result'] != 'success': - return - # print (wati_contacts) - json_dump = json.dumps(wati_contacts, indent=4, sort_keys=True) - contact_list = json.loads(json_dump)['contact_list'] - id = json.loads(contact_list)['id'] - print(id) - + # this commented code not run smoothly, need more time + # change to scheduler + # if not new_header.perusahaan or not new_header.email: + # self._get_attribute_wati(new_header) return def _convert_to_leads(self): @@ -226,6 +189,69 @@ class WatiHistory(models.Model): expired_date = fields.Datetime(string='Expired Date') email = fields.Char(string='Email') perusahaan = fields.Char(string='Perusahaan') + is_get_attribute = fields.Boolean(string='Get Attribute', default=False) + + def _get_attribute_wati(self, test): + # url = 'https://live-server-2106.wati.io/api/v1/getContacts' + + # cookies = { + # 'affinity': '1701232090.884.1520.321410|ff187ffce9bc0bae13542bb446e41008', + # } + + # headers = { + # 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3MGM5ZmJhNy00MWRlLTRkMWEtYjY2NS1hM2Q5ODc2ZjhlZWIiLCJ1bmlxdWVfbmFtZSI6InR5YXNAaW5kb3Rla25pay5jb20iLCJuYW1laWQiOiJ0eWFzQGluZG90ZWtuaWsuY29tIiwiZW1haWwiOiJ0eWFzQGluZG90ZWtuaWsuY29tIiwiYXV0aF90aW1lIjoiMTEvMjkvMjAyMyAwNDoxNzo0NyIsImRiX25hbWUiOiIyMTA2IiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiQURNSU5JU1RSQVRPUiIsImV4cCI6MjUzNDAyMzAwODAwLCJpc3MiOiJDbGFyZV9BSSIsImF1ZCI6IkNsYXJlX0FJIn0.--KHv4GCOG2MM3lNW9Nm-0-d8OAVpn5kbcSX4JKqATQ', + # # 'Cookie': 'affinity=1701232090.884.1520.321410|ff187ffce9bc0bae13542bb446e41008', + # } + + # files = { + # 'pageSize': (None, '1'), + # 'pageNumber': (None, '1'), + # 'name': (None, ''), + # 'attribute': (None, '[{name: "phone", operator: "contain", value: "6285751430014"}]'), + # 'createdDate': (None, ''), + # } + + # response = requests.get(url, cookies=cookies, headers=headers, files=files) + # print(response.json()) + domain = [ + '&', + ('is_get_attribute', '=', False), + '|', + ('perusahaan', '=', False), + ('email', '=', False), + ]#TODO must flagged after get attribute + limit = 50 + wati_histories = self.env['wati.history'].search(domain, limit=limit) + count = 0 + for wati_history in wati_histories: + count += 1 + _logger.info('[Parse Notification] Process: %s/%s' % (str(count), str(limit))) + wati_api = self.env['wati.api'] + params = { + 'pageSize':1, + 'pageNumber':1, + 'attribute':[{'name': "phone", 'operator': "contain", 'value': wati_history.wa_id}], + } + wati_contacts = wati_api.http_get('/api/v1/getContacts', params) + if wati_contacts['result'] != 'success': + return + json_dump = json.dumps(wati_contacts, indent=4, sort_keys=True) + contact_list = json.loads(json_dump)['contact_list'] + perusahaan = email = '' + for data in contact_list: + custom_params = data['customParams'] + for custom_param in custom_params: + name = custom_param['name'] + value = custom_param['value'] + if name == 'perusahaan': + perusahaan = value + elif name == 'email': + email = value + # end for 2 + # end for 1 + wati_history.perusahaan = perusahaan + wati_history.email = email + wati_history.get_attribute = True # @api.onchange('last_reply_date') # def _compute_expired_date(self): -- cgit v1.2.3 From 437ed107ee1730c38932ae6f1d22e7095617d61c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 1 Dec 2023 08:14:46 +0700 Subject: bug fix wati scheduler --- indoteknik_custom/models/wati.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py index 00b46360..d9fb7247 100644 --- a/indoteknik_custom/models/wati.py +++ b/indoteknik_custom/models/wati.py @@ -191,7 +191,7 @@ class WatiHistory(models.Model): perusahaan = fields.Char(string='Perusahaan') is_get_attribute = fields.Boolean(string='Get Attribute', default=False) - def _get_attribute_wati(self, test): + def _get_attribute_wati(self): # url = 'https://live-server-2106.wati.io/api/v1/getContacts' # cookies = { @@ -219,7 +219,7 @@ class WatiHistory(models.Model): '|', ('perusahaan', '=', False), ('email', '=', False), - ]#TODO must flagged after get attribute + ] limit = 50 wati_histories = self.env['wati.history'].search(domain, limit=limit) count = 0 @@ -251,7 +251,7 @@ class WatiHistory(models.Model): # end for 1 wati_history.perusahaan = perusahaan wati_history.email = email - wati_history.get_attribute = True + wati_history.is_get_attribute = True # @api.onchange('last_reply_date') # def _compute_expired_date(self): -- cgit v1.2.3 From 2ff685ec17c73b72cad92fbe8e7d4eb951bc2b89 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Dec 2023 09:51:13 +0700 Subject: change attrs no_faktur_pajak on account.move --- indoteknik_custom/models/account_move.py | 7 ------- indoteknik_custom/views/account_move.xml | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index d55cca38..699191d6 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -32,13 +32,6 @@ class AccountMove(models.Model): no_faktur_pajak = fields.Char(string='No Faktur Pajak') date_completed = fields.Datetime(string='Date Completed') - @api.onchange('efaktur_id') - def change_efaktur_id(self): - for invoice in self: - if not invoice.efaktur_id: - return - invoice.no_faktur_pajak = invoice.efaktur_id.name - def _compute_due_line(self): for invoice in self: invoice.due_line = self.env['due.extension.line'].search([ diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 1721abb6..b0a206bf 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -17,7 +17,7 @@ - + pdf_viewer -- cgit v1.2.3 From ba29eec0050a0e47c9344f4a7fd4e42785779a53 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Dec 2023 16:20:30 +0700 Subject: tracking field unlock on reconcile --- indoteknik_custom/models/account_bank_statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_bank_statement.py b/indoteknik_custom/models/account_bank_statement.py index 23008f13..61e9ca31 100644 --- a/indoteknik_custom/models/account_bank_statement.py +++ b/indoteknik_custom/models/account_bank_statement.py @@ -4,7 +4,7 @@ from odoo.exceptions import AccessError, UserError, ValidationError class AccountBankStatement(models.Model): _inherit = "account.bank.statement" - is_edit = fields.Boolean(string='Unlock', default=False) + is_edit = fields.Boolean(string='Unlock', default=False, tracking=True) def is_edited(self): if not self.env.user.is_admin_reconcile: -- cgit v1.2.3 From 02a1cfe4a4166d1b10ac82d9d89a1be64c870649 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 6 Dec 2023 11:05:10 +0700 Subject: add note for purchase order line --- indoteknik_custom/models/purchase_order_line.py | 1 + indoteknik_custom/views/purchase_order.xml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 2e91bb69..b082eae9 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -31,6 +31,7 @@ class PurchaseOrderLine(models.Model): price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') indent = fields.Boolean(string='Indent', help='centang ini jika barang indent') + note = fields.Char(string='Note') def compute_price_vendor(self): for line in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 08dde8e1..df174257 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -100,7 +100,7 @@ - + @@ -183,6 +183,7 @@ + -- cgit v1.2.3 From 29577f0e4a62a3ff74baa7a7a28c1b978d80942b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 7 Dec 2023 11:48:39 +0700 Subject: add field ltc on line purchase orders --- indoteknik_custom/models/purchase_order_line.py | 1 + indoteknik_custom/views/purchase_order.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index b082eae9..b2bfc7cd 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -31,6 +31,7 @@ class PurchaseOrderLine(models.Model): price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') indent = fields.Boolean(string='Indent', help='centang ini jika barang indent') + is_ltc = fields.Boolean(string='Is LTC?', help='centang ini jika barang sudah di LTC') note = fields.Char(string='Note') def compute_price_vendor(self): diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index df174257..b5a9b4ad 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -183,6 +183,7 @@ + -- cgit v1.2.3 From 46feda7156435e96faf0ff0c6c5297b8d3355375 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 7 Dec 2023 14:16:46 +0700 Subject: change naming of is ltc --- indoteknik_custom/models/purchase_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index b2bfc7cd..c6ef2aab 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -31,7 +31,7 @@ class PurchaseOrderLine(models.Model): price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') indent = fields.Boolean(string='Indent', help='centang ini jika barang indent') - is_ltc = fields.Boolean(string='Is LTC?', help='centang ini jika barang sudah di LTC') + is_ltc = fields.Boolean(string='Sudah di LTC', help='centang ini jika barang sudah di LTC') note = fields.Char(string='Note') def compute_price_vendor(self): -- cgit v1.2.3 From 8e38bd3992101ab43c3d64c58f2a52131c675a19 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 8 Dec 2023 09:21:50 +0700 Subject: add default is ltc --- indoteknik_custom/models/purchase_order_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index c6ef2aab..eced5d43 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -31,7 +31,7 @@ class PurchaseOrderLine(models.Model): price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') indent = fields.Boolean(string='Indent', help='centang ini jika barang indent') - is_ltc = fields.Boolean(string='Sudah di LTC', help='centang ini jika barang sudah di LTC') + is_ltc = fields.Boolean(string='Sudah di LTC', default=False, help='centang ini jika barang sudah di LTC') note = fields.Char(string='Note') def compute_price_vendor(self): -- cgit v1.2.3 From c63d12bb9192ce845aace7489939c47c24973c66 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 8 Dec 2023 15:00:16 +0700 Subject: Update get API Product breadcrumb source field --- indoteknik_api/controllers/api_v1/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 1b698f26..ce0ca406 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -29,7 +29,7 @@ class Product(controller.Controller): category = product.public_categ_ids[0] while category: categories.append({'id': category.id, 'name': category.name}) - category = category.parent_frontend_id + category = category.parent_id categories.reverse() return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')]) -- cgit v1.2.3