summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/automatic_purchase.py6
-rw-r--r--indoteknik_custom/models/ip_lookup.py37
-rw-r--r--indoteknik_custom/models/res_partner.py6
-rwxr-xr-xindoteknik_custom/models/sale_monitoring_detail.py1
4 files changed, 42 insertions, 8 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index 60444b6a..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.id == 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 = {
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')
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/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