summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-12-08 15:31:46 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-12-08 15:31:46 +0700
commitde6039ab7675d91bcfcb67747d3c72be95a379e6 (patch)
treedf1fa2d9f235298988045c5be5a8e60b9951fd13
parentc1f7742c254898fa5981e8ca7d870ac42d3f8346 (diff)
parentc63d12bb9192ce845aace7489939c47c24973c66 (diff)
Merge branch 'production' into change/feature/promotion-program
-rw-r--r--indoteknik_api/controllers/api_v1/product.py2
-rw-r--r--indoteknik_custom/models/account_bank_statement.py2
-rw-r--r--indoteknik_custom/models/account_move.py7
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py2
-rw-r--r--indoteknik_custom/models/wati.py108
-rw-r--r--indoteknik_custom/views/account_move.xml2
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml4
7 files changed, 75 insertions, 52 deletions
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')])
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:
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/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py
index 2e91bb69..eced5d43 100755
--- a/indoteknik_custom/models/purchase_order_line.py
+++ b/indoteknik_custom/models/purchase_order_line.py
@@ -31,6 +31,8 @@ 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', default=False, help='centang ini jika barang sudah di LTC')
+ note = fields.Char(string='Note')
def compute_price_vendor(self):
for line in self:
diff --git a/indoteknik_custom/models/wati.py b/indoteknik_custom/models/wati.py
index aa63fe92..d9fb7247 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):
+ # 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),
+ ]
+ 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.is_get_attribute = True
# @api.onchange('last_reply_date')
# def _compute_expired_date(self):
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 @@
<field name="date_completed" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/>
</field>
<field name="efaktur_document" position="before">
- <field name="no_faktur_pajak" readonly="1"/>
+ <field name="no_faktur_pajak" attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}"/>
</field>
<field name="efaktur_document" position="attributes">
<attribute name="widget">pdf_viewer</attribute>
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 08dde8e1..b5a9b4ad 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -100,7 +100,7 @@
</xpath>
<xpath expr="//form/sheet/notebook/page[@name='purchase_delivery_invoice']" position="before">
- <page string="Indent" name="purchase_order_lines_indent">
+ <page string="Info" name="purchase_order_lines_indent">
<field name="purchase_order_lines"/>
</page>
</xpath>
@@ -183,6 +183,8 @@
<tree editable="top" create="false" delete="false">
<field name="product_id" readonly="1"/>
<field name="indent"/>
+ <field name="is_ltc"/>
+ <field name="note"/>
</tree>
</field>
</record>