From 539a2bc4e311ebf5ec3ed8b43d4b0fd433ccecbd Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 10 Apr 2023 13:26:06 +0700 Subject: auto parsing lookup ip and looked last data parsing --- indoteknik_custom/models/ip_lookup.py | 37 ++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/ip_lookup.py b/indoteknik_custom/models/ip_lookup.py index 0fbb03ea..244982c0 100644 --- a/indoteknik_custom/models/ip_lookup.py +++ b/indoteknik_custom/models/ip_lookup.py @@ -41,12 +41,38 @@ class IpLookup(models.Model): logs = self.env['ip.lookup.line'].search(domain, limit=45, order='create_date asc') for log in logs: try: - ipinfo = requests.get('http://ip-api.com/json/%s' % log.ip_address).json() - del ipinfo['status'] - log.lookup = json.dumps(ipinfo, indent=4, sort_keys=True) + query = [ + ('ip_address', '=', log.ip_address), + ('lookup', '!=', False) + ] + last_data = self.env['ip.lookup.line'].search(query, limit=1) + if last_data: + log.lookup = last_data.lookup + country = json.loads(last_data.lookup)['country'] + timezone = json.loads(last_data)['timezone'] + else: + ipinfo = requests.get('http://ip-api.com/json/%s' % log.ip_address).json() + del ipinfo['status'] + lookup_json = json.dumps(ipinfo, indent=4, sort_keys=True) + log.lookup = lookup_json + country = json.loads(lookup_json)['country'] + timezone = json.loads(lookup_json)['timezone'] + log.country = country + log.timezone = timezone + log.continent = timezone.split('/')[0] except: - log.lookup = '' + # log.lookup = '' + _logger.info('Failed parsing IP Lookup Line %s' % log.id) + def _load_info_address_lookup(self): + lines = self.env['ip.lookup.line'].search([('country', '=', False), ('lookup', '!=', False)], limit=500) + for line in lines: + line.country = json.loads(line.lookup)['country'] + timezone = json.loads(line.lookup)['timezone'] + continent = timezone.split('/')[0] + line.timezone = timezone + line.continent = continent + _logger.info('Success parsing ip lookup line id %s' % line.id) class IpLookupLine(models.Model): _name = 'ip.lookup.line' @@ -56,4 +82,5 @@ class IpLookupLine(models.Model): ip_address = fields.Char(string='IP Address') lookup = fields.Char(string='Lookup') country = fields.Char(string='Country') - + timezone = fields.Char(string='Timezone') + continent = fields.Char(string='Continent', help='diparsing dari field timezone') -- cgit v1.2.3 From 6fc4731e24f1e6f105676273695262f5da059faf Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 10 Apr 2023 15:17:38 +0700 Subject: add group partner and fix automatic purchase --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/automatic_purchase.py | 2 +- indoteknik_custom/models/res_partner.py | 6 +++ indoteknik_custom/security/ir.model.access.csv | 3 +- indoteknik_custom/views/group_partner.xml | 55 ++++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/views/group_partner.xml (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 5873d73a..6e67afe1 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -11,6 +11,7 @@ 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'vit_kelurahan'], 'data': [ 'security/ir.model.access.csv', + 'views/group_partner.xml', 'views/blog_post.xml', 'views/coupon_program.xml', 'views/delivery_order.xml', diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 60444b6a..f2e7d9e9 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -45,7 +45,7 @@ class AutomaticPurchase(models.Model): ], order='brand_id') count = brand_id = 0 for product in products_vendors: - if vendor.id == 5571 and (count == 200 or brand_id != product.brand_id.id): + if vendor['partner_id'][0] == 5571 and (count == 200 or brand_id != product.brand_id.id): count = 0 counter_po_number += 1 new_po = self.env['purchase.order'].create([param_header]) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index ad88957f..eaf93717 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -1,5 +1,9 @@ from odoo import models, fields +class GroupPartner(models.Model): + _name = 'group.partner' + + name = fields.Char(string='Name') class ResPartner(models.Model): _inherit = 'res.partner' @@ -7,3 +11,5 @@ class ResPartner(models.Model): reference_number = fields.Char(string="Reference Number") company_type_id = fields.Many2one('res.partner.company_type', string='Company Type') custom_pricelist_id = fields.Many2one('product.pricelist', string='Price Matrix') + group_partner_id = fields.Many2one('group.partner', string='Group Partner') + diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 1788c77f..f7de6d3f 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -44,4 +44,5 @@ access_uangmuka_pembelian,access.uangmuka.pembelian,model_uangmuka_pembelian,,1, access_automatic_purchase,access.automatic.purchase,model_automatic_purchase,,1,1,1,1 access_automatic_purchase_line,access.automatic.purchase.line,model_automatic_purchase_line,,1,1,1,1 access_automatic_purchase_match,access.automatic.purchase.match,model_automatic_purchase_match,,1,1,1,1 -access_apache_solr,access.apache.solr,model_apache_solr,,1,1,1,1 \ No newline at end of file +access_apache_solr,access.apache.solr,model_apache_solr,,1,1,1,1 +access_group_partner,access.group.partner,model_group_partner,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/group_partner.xml b/indoteknik_custom/views/group_partner.xml new file mode 100644 index 00000000..4d5fd923 --- /dev/null +++ b/indoteknik_custom/views/group_partner.xml @@ -0,0 +1,55 @@ + + + + group.partner.tree + group.partner + + + + + + + + + group.partner.form + group.partner + +
+ + + + + + + +
+
+
+ + + group.partner.list.select + group.partner + + + + + + + + + + Group Partner + ir.actions.act_window + group.partner + + tree,form + + + +
\ No newline at end of file -- cgit v1.2.3 From 8415d007f283af56432bcd1435b46c173070f4fc Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 10 Apr 2023 15:31:29 +0700 Subject: group partner in xml --- indoteknik_custom/views/res_partner.xml | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 47f41ab2..a9372da0 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -11,6 +11,7 @@ + -- cgit v1.2.3 From cc29232e4b935ab2adcc20e177c2bc313cc5f373 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 10 Apr 2023 15:46:05 +0700 Subject: bug fix split po --- indoteknik_custom/models/automatic_purchase.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index f2e7d9e9..eea66b99 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -45,7 +45,7 @@ class AutomaticPurchase(models.Model): ], order='brand_id') count = brand_id = 0 for product in products_vendors: - if vendor['partner_id'][0] == 5571 and (count == 200 or brand_id != product.brand_id.id): + if count == 200 or brand_id != product.brand_id.id: count = 0 counter_po_number += 1 new_po = self.env['purchase.order'].create([param_header]) @@ -55,8 +55,8 @@ class AutomaticPurchase(models.Model): 'order_id': new_po.id }]) self.env.cr.commit() - else: - new_po = self.env['purchase.order'].create([param_header]) + # else: + # new_po = self.env['purchase.order'].create([param_header]) brand_id = product.brand_id.id count += 10 param_line = { -- cgit v1.2.3 From 3b5871b8c364e819a2fbaf268e4693e848e6af0a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 11 Apr 2023 13:56:41 +0700 Subject: add validation qty available in sales monitoring --- indoteknik_custom/models/sale_monitoring_detail.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom') diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index 553ec21f..82bd5c48 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -76,6 +76,7 @@ class SaleMonitoringDetail(models.Model): WHERE pt.type IN ('consu','product') AND so.state IN ('sale','done') AND so.create_date >= '2022-08-10' + and sol.product_uom_qty > get_qty_available(sol.product_id) ) a WHERE a.qty_so_delivered > a.qty_so_invoiced -- cgit v1.2.3