diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-04-11 13:57:01 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-04-11 13:57:01 +0700 |
| commit | 000a7fa68a738843c443145c1a8d102783e04fac (patch) | |
| tree | 04b7c6bf423ce0cf93ea4a526408d71426caaf9e /indoteknik_custom | |
| parent | d1b86303b0934c9f6348e7016822d449349540d3 (diff) | |
| parent | 3b5871b8c364e819a2fbaf268e4693e848e6af0a (diff) | |
Merge branch 'release' into flashsale-solr
Diffstat (limited to 'indoteknik_custom')
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 6 | ||||
| -rw-r--r-- | indoteknik_custom/models/ip_lookup.py | 37 | ||||
| -rw-r--r-- | indoteknik_custom/models/res_partner.py | 6 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring_detail.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/group_partner.xml | 55 | ||||
| -rw-r--r-- | indoteknik_custom/views/res_partner.xml | 1 |
8 files changed, 101 insertions, 9 deletions
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..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 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record id="group_partner_tree" model="ir.ui.view"> + <field name="name">group.partner.tree</field> + <field name="model">group.partner</field> + <field name="arch" type="xml"> + <tree> + <field name="name"/> + </tree> + </field> + </record> + + <record id="group_partner_form" model="ir.ui.view"> + <field name="name">group.partner.form</field> + <field name="model">group.partner</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <group> + <field name="name"/> + </group> + </group> + </sheet> + </form> + </field> + </record> + + <record id="view_group_partner_filter" model="ir.ui.view"> + <field name="name">group.partner.list.select</field> + <field name="model">group.partner</field> + <field name="priority" eval="15"/> + <field name="arch" type="xml"> + <search string="Search Name"> + <field name="name"/> + </search> + </field> + </record> + + <record id="group_partner_action" model="ir.actions.act_window"> + <field name="name">Group Partner</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">group.partner</field> + <field name="search_view_id" ref="view_group_partner_filter"/> + <field name="view_mode">tree,form</field> + </record> + + <menuitem + id="menu_group_partner" + name="Group Partner" + parent="contacts.res_partner_menu_config" + sequence="5" + action="group_partner_action" + /> +</odoo>
\ No newline at end of file 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 @@ </field> <field name="industry_id" position="after"> <field name="company_type_id"/> + <field name="group_partner_id"/> </field> </field> </record> |
