diff --git a/ro_wechat_redirect/__init__.py b/ro_wechat_redirect/__init__.py new file mode 100644 index 000000000..aa4d0fd63 --- /dev/null +++ b/ro_wechat_redirect/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import controllers +from . import models diff --git a/ro_wechat_redirect/__manifest__.py b/ro_wechat_redirect/__manifest__.py new file mode 100644 index 000000000..b5b69734f --- /dev/null +++ b/ro_wechat_redirect/__manifest__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +{ + 'name': "ro_wechat_redirect", + + 'summary': "自动登录", + + 'description': """ + + """, + + 'author': "", + # 'website': "https://www.yourcompany.com", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml + # for the full list + 'category': 'basic', + 'version': '0.1', + + # any module necessary for this one to work correctly + # 'depends': ['base', 'base_address_extended', 'sale', 'purchase'], + 'depends': ['base'], + + # always loaded + 'data': [ + + ], + "assets": { + + }, + "application": True, +} diff --git a/ro_wechat_redirect/controllers/__init__.py b/ro_wechat_redirect/controllers/__init__.py new file mode 100644 index 000000000..b0f26a9a6 --- /dev/null +++ b/ro_wechat_redirect/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import controllers diff --git a/ro_wechat_redirect/controllers/controllers.py b/ro_wechat_redirect/controllers/controllers.py new file mode 100644 index 000000000..fd2b59923 --- /dev/null +++ b/ro_wechat_redirect/controllers/controllers.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from odoo import http +from odoo.addons.web.controllers.home import Home +from odoo.http import request + + + +class HomeExtend(Home): + @http.route() + def web_login(self, redirect=None, **kw): + oauth_access_token = http.request.params.get('oauth_access_token') + if oauth_access_token: + login = kw.get('oauth_uid') + if login != False: + request.session.authenticate(request.session.db, login, oauth_access_token) + + result = super(HomeExtend, self).web_login(redirect, **kw) + return result diff --git a/ro_wechat_redirect/models/__init__.py b/ro_wechat_redirect/models/__init__.py new file mode 100644 index 000000000..741ed460c --- /dev/null +++ b/ro_wechat_redirect/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import res_users diff --git a/ro_wechat_redirect/models/res_users.py b/ro_wechat_redirect/models/res_users.py new file mode 100644 index 000000000..e01c5ae4e --- /dev/null +++ b/ro_wechat_redirect/models/res_users.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.models import INSERT_BATCH_SIZE +from odoo.tools import split_every +from odoo.exceptions import UserError +import logging + +_logger = logging.getLogger(__name__) + + +class ResUsers(models.Model): + _inherit = "res.users" + + def _check_credentials(self, password, env): + """ Validates the current user's password. + + Override this method to plug additional authentication methods. + + Overrides should: + + * call `super` to delegate to parents for credentials-checking + * catch AccessDenied and perform their own checking + * (re)raise AccessDenied if the credentials are still invalid + according to their own validation method + + When trying to check for credentials validity, call _check_credentials + instead. + """ + """ Override this method to plug additional authentication methods""" + if len(self.env['res.users'].sudo().search([('oauth_access_token', '=', password)]))>0: + return True + return super(ResUsers, self)._check_credentials(password, env) + + # user_id = self.env.user + # # 消息通知URL: + # url = f'/web/login?oauth_access_token={user_id.oauth_access_token}&oauth_uid={user_id.oauth_access_token}#action={action}&model={model}&view_type={view_type}&menu_id={menu_id}' + diff --git a/tree_view_advanced_filter/LICENSE b/tree_view_advanced_filter/LICENSE new file mode 100644 index 000000000..b01eaf1b7 --- /dev/null +++ b/tree_view_advanced_filter/LICENSE @@ -0,0 +1,27 @@ +Odoo Proprietary License v1.0 + +This software and associated files (the "Software") may only be used (executed, +modified, executed after modifications) if you have purchased a valid license +from the authors, typically via Odoo Apps, or if you have received a written +agreement from the authors of the Software (see the COPYRIGHT file). + +You may develop Odoo modules that use the Software as a library (typically +by depending on it, importing it and using its resources), but without copying +any source code or material from the Software. You may distribute those +modules under the license of your choice, provided that this license is +compatible with the terms of the Odoo Proprietary License (For example: +LGPL, MIT, or proprietary licenses similar to this one). + +It is forbidden to publish, distribute, sublicense, or sell copies of the Software +or modified copies of the Software. + +The above copyright notice and this permission notice must be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/tree_view_advanced_filter/__init__.py b/tree_view_advanced_filter/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/tree_view_advanced_filter/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/tree_view_advanced_filter/__manifest__.py b/tree_view_advanced_filter/__manifest__.py new file mode 100644 index 000000000..1c6a229ce --- /dev/null +++ b/tree_view_advanced_filter/__manifest__.py @@ -0,0 +1,74 @@ +# Part of Odoo, Aktiv Software. +# See LICENSE file for full copyright & licensing details. + +# Author: Aktiv Software. +# mail: odoo@aktivsoftware.com +# Copyright (C) 2015-Present Aktiv Software PVT. LTD. +# Contributions: +# Aktiv Software: +# - Kuldip Trapasiya +# - Tanvi Gajera + +{ + "name": "Tree View Advanced Search / Direct Filter in List", + "version": "17.0.1.0.0", + "category": "Advanced search on Tree view", + "summary": """This module allows a user to directly filter on the Tree / List View. + The data will be filtered Runtime. + List Filter , + Filter List, + Column Filter, + Tree Filter, + Filter Tree, + Advance Search, + Search Advance, + Tree Search, + Direct Search, + Fast Search, + Quick Search, + Dynamic Search, + Dynamic Tree, + Data Search, + Search Data, + Data search in Tree, + X2many search, + X2many search in Tree + """, + "description": """ + This module allows a user to directly single/multiple filter on the Tree / List View. + The data will be filtered Runtime. Columns can be directly searched on the Tree View. + List Filter + Column Filter + Tree Filter + Advance Search + Tree Search + Direct Search + Fast Search + Quick Search + Dynamic Search + Dynamic Tree + Data Search + Data search in Tree + X2many search + X2many search in Tree + """, + "author": "Aktiv Software", + "website": "http://www.aktivsoftware.com", + "license": "OPL-1", + "price": 95.00, + "currency": "USD", + "depends": ["web", "sale_management"], + "data": [], + "assets": { + "web.assets_backend": [ + # Custum Library + "tree_view_advanced_filter/static/src/libs/**/*", + "tree_view_advanced_filter/static/src/tree_view_advanced_filter/**/*", + "tree_view_advanced_filter/static/src/web_list_num/**/*", + ] + }, + "images": ["static/description/banner.jpg"], + "installable": True, + "auto_install": False, + "application": False, +} diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_1.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_1.jpg new file mode 100644 index 000000000..3b0811829 Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_1.jpg differ diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_2.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_2.jpg new file mode 100644 index 000000000..cfea4fbb2 Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_2.jpg differ diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_3.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_3.jpg new file mode 100644 index 000000000..c69bd50eb Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_3.jpg differ diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_4.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_4.jpg new file mode 100644 index 000000000..8962e9e23 Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_4.jpg differ diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_5.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_5.jpg new file mode 100644 index 000000000..0ef28a27f Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_5.jpg differ diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_6.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_6.jpg new file mode 100644 index 000000000..9289cb930 Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_6.jpg differ diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_7.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_7.jpg new file mode 100644 index 000000000..53af1fa3e Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_7.jpg differ diff --git a/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_8.jpg b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_8.jpg new file mode 100644 index 000000000..e993b735e Binary files /dev/null and b/tree_view_advanced_filter/static/description/Browser_Screen_Mockup_8.jpg differ diff --git a/tree_view_advanced_filter/static/description/GIF.gif b/tree_view_advanced_filter/static/description/GIF.gif new file mode 100644 index 000000000..c13fbb4d4 Binary files /dev/null and b/tree_view_advanced_filter/static/description/GIF.gif differ diff --git a/tree_view_advanced_filter/static/description/banner.jpg b/tree_view_advanced_filter/static/description/banner.jpg new file mode 100644 index 000000000..1e0541de4 Binary files /dev/null and b/tree_view_advanced_filter/static/description/banner.jpg differ diff --git a/tree_view_advanced_filter/static/description/default_icons/Odoo_Consulting.png b/tree_view_advanced_filter/static/description/default_icons/Odoo_Consulting.png new file mode 100644 index 000000000..1f244ce23 Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/Odoo_Consulting.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/Odoo_Customization.png b/tree_view_advanced_filter/static/description/default_icons/Odoo_Customization.png new file mode 100644 index 000000000..b2ae9f366 Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/Odoo_Customization.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/Odoo_Implementation.png b/tree_view_advanced_filter/static/description/default_icons/Odoo_Implementation.png new file mode 100644 index 000000000..153001076 Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/Odoo_Implementation.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/Odoo_Integration.png b/tree_view_advanced_filter/static/description/default_icons/Odoo_Integration.png new file mode 100644 index 000000000..841418705 Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/Odoo_Integration.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/Odoo_Migration.png b/tree_view_advanced_filter/static/description/default_icons/Odoo_Migration.png new file mode 100644 index 000000000..c65aa065a Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/Odoo_Migration.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/Odoo_Support.png b/tree_view_advanced_filter/static/description/default_icons/Odoo_Support.png new file mode 100644 index 000000000..244d09578 Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/Odoo_Support.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/aktiv-logo.png b/tree_view_advanced_filter/static/description/default_icons/aktiv-logo.png new file mode 100644 index 000000000..b80517cc9 Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/aktiv-logo.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/arrow.png b/tree_view_advanced_filter/static/description/default_icons/arrow.png new file mode 100644 index 000000000..4e2533f15 Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/arrow.png differ diff --git a/tree_view_advanced_filter/static/description/default_icons/check.png b/tree_view_advanced_filter/static/description/default_icons/check.png new file mode 100644 index 000000000..691a762ae Binary files /dev/null and b/tree_view_advanced_filter/static/description/default_icons/check.png differ diff --git a/tree_view_advanced_filter/static/description/icon.png b/tree_view_advanced_filter/static/description/icon.png new file mode 100644 index 000000000..ed61ff6e7 Binary files /dev/null and b/tree_view_advanced_filter/static/description/icon.png differ diff --git a/tree_view_advanced_filter/static/description/index.html b/tree_view_advanced_filter/static/description/index.html new file mode 100644 index 000000000..612d6d7e5 --- /dev/null +++ b/tree_view_advanced_filter/static/description/index.html @@ -0,0 +1,542 @@ +
+
+
+
+
+
+ +
+
+
+ Enterprise +
+
+ Community +
+
+ Odoo.Sh +
+
+ Self Hosted +
+
+
+
+
+
+
+
+
+ +
+

+ Tree View Advanced Search / Direct Filter in List +

+

+ The module allows you to quickly search records from the list view. +

+
+
+ +
+
+ + +
+ +
+ + +
+
+

+ Overview +

+
+

+ Unlike the default search functionality of Odoo, this custom app allows user to use dynamic single/multiple + search filter on the Tree / List View in all the base and custom Odoo modules. The data will be + filtered Runtime. + For e.g., if user wants to search single/multiple quotation for customers in the invoice module, he/she can + search the single as well as multi customers by their invoice number, invoice creation date, delivery date, customer + name, invoice date, source document, sales person, company, due date, tax, total amount, amount + due, status, etc. + In short, each field/column in the list/tree view will contain an advanced single/multiple filter option to + easily access the data anywhere. +

+
+
+ + +
+
+

+ Features +

+
+
+
+
+
+
+ +

Single/multiple search runtime on every tree views with + advanced filter option

+
+
+
+
+ +

In Date or Datetime fields, a range + selection will be visible

+
+
+
+
+
+
+
+
+ +

User can easily search on text, + date/datetime, many2one, integer/float columns

+
+
+
+
+ +

Integer and Float columns will search + for the exact value

+
+
+
+
+
+
+
+
+ +

Single/multi Search runtime on every tree views of + the relational fields(X2many) with advanced filter option

+
+
+
+
+ +

Apply multiple search filters on single column. +

+
+
+
+
+
+
+
+ + +
+
+

+ Setup & Configuration +

+
+ +
+

+ No prerequisites required before installation. +

+
    +
  • +

    Required Apps +

    +

    + Web +

    +
  • +
+
+ +
+

+ Configuration. +

+
+ +
+
+ +
+

No configurations. +

+
+
+
+
+
+ + +
+
+

+ Screenshots +

+
+
+
+ +
+

Single/multi search Runtime on Tree Views +

+

+ After Installing this module, User will see an extra row in every tree view which + includes the column filter. + User can easily search on text, date/datetime, many2one, integer/float columns. +

+
+
+ +
+ +
+
+ +
+

Apply multiple search filters on text, many2one, integer/float columns. +

+
+
+ +
+ + + +
+
+ +
+

Filter will not be visible on widgets and + non-stored compute columns. +

+
+
+ +
+ +
+
+ +
+

Single/multi search Runtime on Tree View of relational fields + (X2many)

+
+
+ +
+ +
+
+ +
+

Apply multiple search filters on single columns

+
+
+ +
+ +
+
+ +
+

Single/ multi filter can be apply on the + folded list view i.e in group by mode. +

+
+
+ +
+
+
+ +
+

Text and M2O Columns. +

+

+ It is very easy to search the data in Many2one and Selection fields. + The record count and the summation of the column value will also be adjusted based + on the data. +

+
+
+ +
+
+
+ +
+

Integer and Float Columns. +

+

+ Integer and Float columns will single/multi search for the exact value inputted by the user. +

+
+
+ +
+
+
+ +
+
+

+ Suggested Apps +

+
+ +
+
+ + +
+
+
+

+ Our Services +

+
+
+
+
+ +
+
+ Odoo + Consulting +
+
+
+
+ +
+
+ Odoo + Customization +
+
+
+
+ +
+
+ Odoo + Implementation +
+
+
+
+ +
+
+ Odoo + Integration +
+
+
+
+ +
+
+ Odoo + Migration +
+
+
+
+ +
+
+ Odoo + Support +
+
+
+
+ + + +
+

+ + + +
+ + Get Help & Support + +

+ +
+ +
+
+
\ No newline at end of file diff --git a/tree_view_advanced_filter/static/description/suggested_apps/ecommerce_contry_restriction.jpg b/tree_view_advanced_filter/static/description/suggested_apps/ecommerce_contry_restriction.jpg new file mode 100644 index 000000000..c230504b7 Binary files /dev/null and b/tree_view_advanced_filter/static/description/suggested_apps/ecommerce_contry_restriction.jpg differ diff --git a/tree_view_advanced_filter/static/description/suggested_apps/garbage_management.jpg b/tree_view_advanced_filter/static/description/suggested_apps/garbage_management.jpg new file mode 100644 index 000000000..5aabb7970 Binary files /dev/null and b/tree_view_advanced_filter/static/description/suggested_apps/garbage_management.jpg differ diff --git a/tree_view_advanced_filter/static/description/suggested_apps/product_social_media.jpg b/tree_view_advanced_filter/static/description/suggested_apps/product_social_media.jpg new file mode 100644 index 000000000..4fbe8ae67 Binary files /dev/null and b/tree_view_advanced_filter/static/description/suggested_apps/product_social_media.jpg differ diff --git a/tree_view_advanced_filter/static/description/suggested_apps/user_activity_log.jpg b/tree_view_advanced_filter/static/description/suggested_apps/user_activity_log.jpg new file mode 100644 index 000000000..6d4f11beb Binary files /dev/null and b/tree_view_advanced_filter/static/description/suggested_apps/user_activity_log.jpg differ diff --git a/tree_view_advanced_filter/static/description/suggested_apps/web_dynamic_dashboard.jpg b/tree_view_advanced_filter/static/description/suggested_apps/web_dynamic_dashboard.jpg new file mode 100644 index 000000000..52649656c Binary files /dev/null and b/tree_view_advanced_filter/static/description/suggested_apps/web_dynamic_dashboard.jpg differ diff --git a/tree_view_advanced_filter/static/description/suggested_apps/website_product_stock.jpg b/tree_view_advanced_filter/static/description/suggested_apps/website_product_stock.jpg new file mode 100644 index 000000000..e38f67b44 Binary files /dev/null and b/tree_view_advanced_filter/static/description/suggested_apps/website_product_stock.jpg differ diff --git a/tree_view_advanced_filter/static/src/css/main.scss b/tree_view_advanced_filter/static/src/css/main.scss new file mode 100644 index 000000000..3506a2d40 --- /dev/null +++ b/tree_view_advanced_filter/static/src/css/main.scss @@ -0,0 +1,71 @@ +.tree_search_item { + cursor: pointer; +} + + +.tree_search_item .selected a:before { + font-family: FontAwesome; + position: absolute; + left: 10px; + top: 10px; +} + +input.input_text{ + transition: all 0.3s ease; +} + +.search_div{ + display: flex; + align-items: center; + border: 1px solid #1a4040; + font-size: 15px !important; + border-radius: 8px; + text-align: center; + overflow: hidden; + padding: 2px; +} +.input_text{ + flex: 2; + border: none!important; +} +.search_button{ + margin: 0px 0px; + border:none +} +.search_button:hover{ + color: blueviolet; +} +.remove_button{ + border:none +} +.remove_button:hover{ + color: indianred; +} +.hidden_button{ +display:none +} +.table_layout +{ +table-layout:auto +} + +.auto-overflow { + overflow: auto !important; +} + +/* Hide scrollbar for Chrome, Safari and Opera */ +.auto-overflow::-webkit-scrollbar { + display: none; +} + +/* Hide scrollbar for IE, Edge and Firefox */ +.auto-overflow { + -ms-overflow-style: none; + /* IE and Edge */ + scrollbar-width: none; + /* Firefox */ +} + +.min-wp-50 { + min-width: 50px !important; +} \ No newline at end of file diff --git a/tree_view_advanced_filter/static/src/js/search_model.js b/tree_view_advanced_filter/static/src/js/search_model.js new file mode 100644 index 000000000..c51f33a8c --- /dev/null +++ b/tree_view_advanced_filter/static/src/js/search_model.js @@ -0,0 +1,13 @@ +// /** @odoo-module */ + +import { SearchModel } from "@web/search/search_model"; +import { patch } from "@web/core/utils/patch"; + +patch(SearchModel.prototype, { + async _reloadSections() { + super._reloadSections(...arguments); + if (this.ak_domains) { + this._domain = this.domain.concat(this.ak_domains); + } + }, +}); diff --git a/tree_view_advanced_filter/static/src/js/tree.js b/tree_view_advanced_filter/static/src/js/tree.js new file mode 100644 index 000000000..50089a33b --- /dev/null +++ b/tree_view_advanced_filter/static/src/js/tree.js @@ -0,0 +1,594 @@ +/** @odoo-module */ + +import { ListRenderer } from "@web/views/list/list_renderer"; +import { browser } from "@web/core/browser/browser"; +import { patch } from "@web/core/utils/patch"; +import { session } from "@web/session"; +import { serialize } from "@web/core/l10n/dates"; +import { serializeDateTime } from "@web/core/l10n/dates"; +import { loadJS, loadCSS } from "@web/core/assets"; +const { onMounted, onPatched } = owl; +const { DateTime } = luxon; + +export const ListRendererCust = { + setup() { + + super.setup(); + browser.sessionStorage.setItem('domainlist', JSON.stringify([])); // Replaced localStorage with sessionStorage + + onMounted(() => { + this._renderSearchPanel() + }); + + onPatched(() => { + this._renderSearchPanel() + }); + }, + + _renderSearchPanel: async function () { + await loadJS("https://cdn.jsdelivr.net/jquery/latest/jquery.min.js") + await loadJS("https://cdn.jsdelivr.net/momentjs/latest/moment.min.js") + await loadJS("https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js") + await loadCSS("https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css") + var List = this.props.list; + const bm_params = List.model.__bm_load_params__; + const rootRef = this.rootRef.el + const tableRef = this.tableRef.el; + tableRef.removeAttribute('style') + var columns = this.allColumns.filter((col) => { + if (col.optional && this.optionalActiveFields[col.name] == false) { + return false; + } + if (col.column_invisible == true || col.column_invisible && col.invisible) { + return false; + } +// if (col.optional == 'hide'){ +// return false; +// } + if (['in_invoice', 'in_refund', 'in_receipt'].includes(this.props.list.evalContext.default_move_type)){ + if (['Vendor', 'Invoice Date'].includes(col.string)) { + return false; + } + } + if (['out_invoice', 'out_refund', 'out_receipt'].includes(this.props.list.evalContext.default_move_type)){ + if (['Customer', 'Bill Date'].includes(col.string)) { + return false; + } + } + if (col.name == 'move_type'){ + return false; + } + return true; + }); + + var $tr1 = $('').append(columns.map(columns => this._renderHeaderCellSearch(columns))); + if (this.hasSelectors) { + $tr1.prepend($('').addClass('o_list_record_selector')); + } + + if (this.isStudioEditable || this.displayOptionalFields) { + $tr1.append($('').addClass('o_list_record_selector')); + } + + if ($(tableRef).find('.search_td').length) { + $(tableRef).find('.search_td').parent().replaceWith($tr1) + } + else { + $tr1.insertAfter($(tableRef).find('tr')[0]); + } + + rootRef.querySelectorAll('thead tr td.search_td input').forEach((a) => a.addEventListener('keyup', this._onfilter.bind(this))); + rootRef.querySelectorAll('.search_button').forEach((a) => a.addEventListener('click', this._onSearch.bind(this))); + rootRef.querySelectorAll('.remove_button').forEach((a) => a.addEventListener('click', this._onRemove.bind(this))); + rootRef.querySelectorAll('thead tr td').forEach((a) => a.addEventListener('keypress', this._onKeyPress.bind(this))); + }, + + _renderHeaderCellSearch: function (node) { + var List = this.props.list + var search_tr = $($('tr')[1]).find('input.input_text') + var old_domain = JSON.parse(browser.sessionStorage.getItem('domainlist')) + var input_dict = {} + var self = this; + var $td = $('', { + class: 'search_td' + }); + + for (var i = 0; i < search_tr.length; i++) { + var field = $(search_tr[i]).attr('name') + var value = $(search_tr[i]).val() + input_dict[String(field)] = value + } + if (node.type != 'field') { + return $td + } + const { + name, + string, + widget, + } = node; + var searched_value = old_domain.filter(function (domain) { + return domain[0] == name; + }); + var widget_list = ["monetary", "date", "many2one_avatar_user", "badge", "task_with_hours", "timesheet_uom", "sol_product_many2one"]; + var value_of_tr = searched_value.length > 0 ? searched_value[0][2] : "" + var field = List.fields[name]; + + if (name) { + $td.attr('data-name', name); + } else if (string) { + $td.attr('data-string', string); + } + if (!field) { + return $td; + } + var description = string || field.string; + + // search elements + var search_div = $('
').attr({ + 'class': 'search_div d-inline-flex auto-overflow' + }); + var $input = $('').attr({ + name: name, + data_name: name, + data_text: string, + placeholder: description, + autocomplete: "autocomplete", + 'class': 'input_text min-wp-50' + }); + var search_button = $('
'),this.parentEl=i.parentEl&&e(i.parentEl).length?e(i.parentEl):e(this.parentEl),this.container=e(i.template).appendTo(this.parentEl),"object"==typeof i.locale&&("string"==typeof i.locale.direction&&(this.locale.direction=i.locale.direction),"string"==typeof i.locale.format&&(this.locale.format=i.locale.format),"string"==typeof i.locale.separator&&(this.locale.separator=i.locale.separator),"object"==typeof i.locale.daysOfWeek&&(this.locale.daysOfWeek=i.locale.daysOfWeek.slice()),"object"==typeof i.locale.monthNames&&(this.locale.monthNames=i.locale.monthNames.slice()),"number"==typeof i.locale.firstDay&&(this.locale.firstDay=i.locale.firstDay),"string"==typeof i.locale.applyLabel&&(this.locale.applyLabel=i.locale.applyLabel),"string"==typeof i.locale.cancelLabel&&(this.locale.cancelLabel=i.locale.cancelLabel),"string"==typeof i.locale.weekLabel&&(this.locale.weekLabel=i.locale.weekLabel),"string"==typeof i.locale.customRangeLabel)){(p=document.createElement("textarea")).innerHTML=i.locale.customRangeLabel;var n=p.value;this.locale.customRangeLabel=n}if(this.container.addClass(this.locale.direction),"string"==typeof i.startDate&&(this.startDate=t(i.startDate,this.locale.format)),"string"==typeof i.endDate&&(this.endDate=t(i.endDate,this.locale.format)),"string"==typeof i.minDate&&(this.minDate=t(i.minDate,this.locale.format)),"string"==typeof i.maxDate&&(this.maxDate=t(i.maxDate,this.locale.format)),"object"==typeof i.startDate&&(this.startDate=t(i.startDate)),"object"==typeof i.endDate&&(this.endDate=t(i.endDate)),"object"==typeof i.minDate&&(this.minDate=t(i.minDate)),"object"==typeof i.maxDate&&(this.maxDate=t(i.maxDate)),this.minDate&&this.startDate.isBefore(this.minDate)&&(this.startDate=this.minDate.clone()),this.maxDate&&this.endDate.isAfter(this.maxDate)&&(this.endDate=this.maxDate.clone()),"string"==typeof i.applyButtonClasses&&(this.applyButtonClasses=i.applyButtonClasses),"string"==typeof i.applyClass&&(this.applyButtonClasses=i.applyClass),"string"==typeof i.cancelButtonClasses&&(this.cancelButtonClasses=i.cancelButtonClasses),"string"==typeof i.cancelClass&&(this.cancelButtonClasses=i.cancelClass),"object"==typeof i.maxSpan&&(this.maxSpan=i.maxSpan),"object"==typeof i.dateLimit&&(this.maxSpan=i.dateLimit),"string"==typeof i.opens&&(this.opens=i.opens),"string"==typeof i.drops&&(this.drops=i.drops),"boolean"==typeof i.showWeekNumbers&&(this.showWeekNumbers=i.showWeekNumbers),"boolean"==typeof i.showISOWeekNumbers&&(this.showISOWeekNumbers=i.showISOWeekNumbers),"string"==typeof i.buttonClasses&&(this.buttonClasses=i.buttonClasses),"object"==typeof i.buttonClasses&&(this.buttonClasses=i.buttonClasses.join(" ")),"boolean"==typeof i.showDropdowns&&(this.showDropdowns=i.showDropdowns),"number"==typeof i.minYear&&(this.minYear=i.minYear),"number"==typeof i.maxYear&&(this.maxYear=i.maxYear),"boolean"==typeof i.showCustomRangeLabel&&(this.showCustomRangeLabel=i.showCustomRangeLabel),"boolean"==typeof i.singleDatePicker&&(this.singleDatePicker=i.singleDatePicker,this.singleDatePicker&&(this.endDate=this.startDate.clone())),"boolean"==typeof i.timePicker&&(this.timePicker=i.timePicker),"boolean"==typeof i.timePickerSeconds&&(this.timePickerSeconds=i.timePickerSeconds),"number"==typeof i.timePickerIncrement&&(this.timePickerIncrement=i.timePickerIncrement),"boolean"==typeof i.timePicker24Hour&&(this.timePicker24Hour=i.timePicker24Hour),"boolean"==typeof i.autoApply&&(this.autoApply=i.autoApply),"boolean"==typeof i.autoUpdateInput&&(this.autoUpdateInput=i.autoUpdateInput),"boolean"==typeof i.linkedCalendars&&(this.linkedCalendars=i.linkedCalendars),"function"==typeof i.isInvalidDate&&(this.isInvalidDate=i.isInvalidDate),"function"==typeof i.isCustomDate&&(this.isCustomDate=i.isCustomDate),"boolean"==typeof i.alwaysShowCalendars&&(this.alwaysShowCalendars=i.alwaysShowCalendars),0!=this.locale.firstDay)for(var r=this.locale.firstDay;r>0;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),r--;var o,h,l;if(void 0===i.startDate&&void 0===i.endDate&&e(this.element).is(":text")){var c=e(this.element).val(),d=c.split(this.locale.separator);o=h=null,2==d.length?(o=t(d[0],this.locale.format),h=t(d[1],this.locale.format)):this.singleDatePicker&&""!==c&&(o=t(c,this.locale.format),h=t(c,this.locale.format)),null!==o&&null!==h&&(this.setStartDate(o),this.setEndDate(h))}if("object"==typeof i.ranges){for(l in i.ranges){o="string"==typeof i.ranges[l][0]?t(i.ranges[l][0],this.locale.format):t(i.ranges[l][0]),h="string"==typeof i.ranges[l][1]?t(i.ranges[l][1],this.locale.format):t(i.ranges[l][1]),this.minDate&&o.isBefore(this.minDate)&&(o=this.minDate.clone());var m=this.maxDate;if(this.maxSpan&&m&&o.clone().add(this.maxSpan).isAfter(m)&&(m=o.clone().add(this.maxSpan)),m&&h.isAfter(m)&&(h=m.clone()),!(this.minDate&&h.isBefore(this.minDate,this.timepicker?"minute":"day")||m&&o.isAfter(m,this.timepicker?"minute":"day"))){var p;(p=document.createElement("textarea")).innerHTML=l;n=p.value;this.ranges[n]=[o,h]}}var f="",this.container.find(".ranges").prepend(f)}"function"==typeof s&&(this.callback=s),this.timePicker||(this.startDate=this.startDate.startOf("day"),this.endDate=this.endDate.endOf("day"),this.container.find(".calendar-time").hide()),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.addClass("auto-apply"),"object"==typeof i.ranges&&this.container.addClass("show-ranges"),this.singleDatePicker&&(this.container.addClass("single"),this.container.find(".drp-calendar.left").addClass("single"),this.container.find(".drp-calendar.left").show(),this.container.find(".drp-calendar.right").hide(),!this.timePicker&&this.autoApply&&this.container.addClass("auto-apply")),(void 0===i.ranges&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyButtonClasses.length&&this.container.find(".applyBtn").addClass(this.applyButtonClasses),this.cancelButtonClasses.length&&this.container.find(".cancelBtn").addClass(this.cancelButtonClasses),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".drp-calendar").on("click.daterangepicker",".prev",e.proxy(this.clickPrev,this)).on("click.daterangepicker",".next",e.proxy(this.clickNext,this)).on("mousedown.daterangepicker","td.available",e.proxy(this.clickDate,this)).on("mouseenter.daterangepicker","td.available",e.proxy(this.hoverDate,this)).on("change.daterangepicker","select.yearselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.monthselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",e.proxy(this.timeChanged,this)),this.container.find(".ranges").on("click.daterangepicker","li",e.proxy(this.clickRange,this)),this.container.find(".drp-buttons").on("click.daterangepicker","button.applyBtn",e.proxy(this.clickApply,this)).on("click.daterangepicker","button.cancelBtn",e.proxy(this.clickCancel,this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":e.proxy(this.show,this),"focus.daterangepicker":e.proxy(this.show,this),"keyup.daterangepicker":e.proxy(this.elementChanged,this),"keydown.daterangepicker":e.proxy(this.keydown,this)}):(this.element.on("click.daterangepicker",e.proxy(this.toggle,this)),this.element.on("keydown.daterangepicker",e.proxy(this.toggle,this))),this.updateElement()};return a.prototype={constructor:a,setStartDate:function(e){"string"==typeof e&&(this.startDate=t(e,this.locale.format)),"object"==typeof e&&(this.startDate=t(e)),this.timePicker||(this.startDate=this.startDate.startOf("day")),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.minDate&&this.startDate.isBefore(this.minDate)&&(this.startDate=this.minDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.maxDate&&this.startDate.isAfter(this.maxDate)&&(this.startDate=this.maxDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.floor(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.isShowing||this.updateElement(),this.updateMonthsInView()},setEndDate:function(e){"string"==typeof e&&(this.endDate=t(e,this.locale.format)),"object"==typeof e&&(this.endDate=t(e)),this.timePicker||(this.endDate=this.endDate.endOf("day")),this.timePicker&&this.timePickerIncrement&&this.endDate.minute(Math.round(this.endDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.endDate.isBefore(this.startDate)&&(this.endDate=this.startDate.clone()),this.maxDate&&this.endDate.isAfter(this.maxDate)&&(this.endDate=this.maxDate.clone()),this.maxSpan&&this.startDate.clone().add(this.maxSpan).isBefore(this.endDate)&&(this.endDate=this.startDate.clone().add(this.maxSpan)),this.previousRightTime=this.endDate.clone(),this.container.find(".drp-selected").html(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.isShowing||this.updateElement(),this.updateMonthsInView()},isInvalidDate:function(){return!1},isCustomDate:function(){return!1},updateView:function(){this.timePicker&&(this.renderTimePicker("left"),this.renderTimePicker("right"),this.endDate?this.container.find(".right .calendar-time select").prop("disabled",!1).removeClass("disabled"):this.container.find(".right .calendar-time select").prop("disabled",!0).addClass("disabled")),this.endDate&&this.container.find(".drp-selected").html(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.updateMonthsInView(),this.updateCalendars(),this.updateFormInputs()},updateMonthsInView:function(){if(this.endDate){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.startDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.startDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM"))&&(this.endDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.endDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM")))return;this.leftCalendar.month=this.startDate.clone().date(2),this.linkedCalendars||this.endDate.month()==this.startDate.month()&&this.endDate.year()==this.startDate.year()?this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"):this.rightCalendar.month=this.endDate.clone().date(2)}else this.leftCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&this.rightCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&(this.leftCalendar.month=this.startDate.clone().date(2),this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.clone().date(2),this.leftCalendar.month=this.maxDate.clone().date(2).subtract(1,"month"))},updateCalendars:function(){if(this.timePicker){var t,e,a,i;if(this.endDate){if(t=parseInt(this.container.find(".left .hourselect").val(),10),e=parseInt(this.container.find(".left .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".left .minuteselect option:last").val(),10)),a=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0,!this.timePicker24Hour)"PM"===(i=this.container.find(".left .ampmselect").val())&&t<12&&(t+=12),"AM"===i&&12===t&&(t=0)}else if(t=parseInt(this.container.find(".right .hourselect").val(),10),e=parseInt(this.container.find(".right .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".right .minuteselect option:last").val(),10)),a=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0,!this.timePicker24Hour)"PM"===(i=this.container.find(".right .ampmselect").val())&&t<12&&(t+=12),"AM"===i&&12===t&&(t=0);this.leftCalendar.month.hour(t).minute(e).second(a),this.rightCalendar.month.hour(t).minute(e).second(a)}this.renderCalendar("left"),this.renderCalendar("right"),this.container.find(".ranges li").removeClass("active"),null!=this.endDate&&this.calculateChosenLabel()},renderCalendar:function(a){var i,s=(i="left"==a?this.leftCalendar:this.rightCalendar).month.month(),n=i.month.year(),r=i.month.hour(),o=i.month.minute(),h=i.month.second(),l=t([n,s]).daysInMonth(),c=t([n,s,1]),d=t([n,s,l]),m=t(c).subtract(1,"month").month(),p=t(c).subtract(1,"month").year(),f=t([p,m]).daysInMonth(),u=c.day();(i=[]).firstDay=c,i.lastDay=d;for(var D=0;D<6;D++)i[D]=[];var g=f-u+this.locale.firstDay+1;g>f&&(g-=7),u==this.locale.firstDay&&(g=f-6);for(var y=t([p,m,g,12,o,h]),k=(D=0,0),b=0;D<42;D++,k++,y=t(y).add(24,"hour"))D>0&&k%7==0&&(k=0,b++),i[b][k]=y.clone().hour(r).minute(o).second(h),y.hour(12),this.minDate&&i[b][k].format("YYYY-MM-DD")==this.minDate.format("YYYY-MM-DD")&&i[b][k].isBefore(this.minDate)&&"left"==a&&(i[b][k]=this.minDate.clone()),this.maxDate&&i[b][k].format("YYYY-MM-DD")==this.maxDate.format("YYYY-MM-DD")&&i[b][k].isAfter(this.maxDate)&&"right"==a&&(i[b][k]=this.maxDate.clone());"left"==a?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var v="left"==a?this.minDate:this.startDate,C=this.maxDate,Y=("left"==a?this.startDate:this.endDate,this.locale.direction,'');Y+="",Y+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(Y+=""),v&&!v.isBefore(i.firstDay)||this.linkedCalendars&&"left"!=a?Y+="":Y+='';var w=this.locale.monthNames[i[1][1].month()]+i[1][1].format(" YYYY");if(this.showDropdowns){for(var P=i[1][1].month(),x=i[1][1].year(),M=C&&C.year()||this.maxYear,I=v&&v.year()||this.minYear,S=x==I,B=x==M,A='";for(var N='")}if(Y+='",C&&!C.isAfter(i.lastDay)||this.linkedCalendars&&"right"!=a&&!this.singleDatePicker?Y+="":Y+='',Y+="",Y+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(Y+='"),e.each(this.locale.daysOfWeek,(function(t,e){Y+=""})),Y+="",Y+="",Y+="",null==this.endDate&&this.maxSpan){var O=this.startDate.clone().add(this.maxSpan).endOf("day");C&&!O.isBefore(C)||(C=O)}for(b=0;b<6;b++){Y+="",this.showWeekNumbers?Y+='":this.showISOWeekNumbers&&(Y+='");for(k=0;k<7;k++){var W=[];i[b][k].isSame(new Date,"day")&&W.push("today"),i[b][k].isoWeekday()>5&&W.push("weekend"),i[b][k].month()!=i[1][1].month()&&W.push("off","ends"),this.minDate&&i[b][k].isBefore(this.minDate,"day")&&W.push("off","disabled"),C&&i[b][k].isAfter(C,"day")&&W.push("off","disabled"),this.isInvalidDate(i[b][k])&&W.push("off","disabled"),i[b][k].format("YYYY-MM-DD")==this.startDate.format("YYYY-MM-DD")&&W.push("active","start-date"),null!=this.endDate&&i[b][k].format("YYYY-MM-DD")==this.endDate.format("YYYY-MM-DD")&&W.push("active","end-date"),null!=this.endDate&&i[b][k]>this.startDate&&i[b][k]'+i[b][k].date()+""}Y+=""}Y+="",Y+="
'+w+"
'+this.locale.weekLabel+""+e+"
'+i[b][0].week()+"'+i[b][0].isoWeek()+"
",this.container.find(".drp-calendar."+a+" .calendar-table").html(Y)},renderTimePicker:function(t){if("right"!=t||this.endDate){var e,a,i,s=this.maxDate;if(!this.maxSpan||this.maxDate&&!this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)||(s=this.startDate.clone().add(this.maxSpan)),"left"==t)a=this.startDate.clone(),i=this.minDate;else if("right"==t){a=this.endDate.clone(),i=this.startDate;var n=this.container.find(".drp-calendar.right .calendar-time");if(""!=n.html()&&(a.hour(isNaN(a.hour())?n.find(".hourselect option:selected").val():a.hour()),a.minute(isNaN(a.minute())?n.find(".minuteselect option:selected").val():a.minute()),a.second(isNaN(a.second())?n.find(".secondselect option:selected").val():a.second()),!this.timePicker24Hour)){var r=n.find(".ampmselect option:selected").val();"PM"===r&&a.hour()<12&&a.hour(a.hour()+12),"AM"===r&&12===a.hour()&&a.hour(0)}a.isBefore(this.startDate)&&(a=this.startDate.clone()),s&&a.isAfter(s)&&(a=s.clone())}e=' ",e+=': ",this.timePickerSeconds){e+=': "}if(!this.timePicker24Hour){e+='"}this.container.find(".drp-calendar."+t+" .calendar-time").html(e)}},updateFormInputs:function(){this.singleDatePicker||this.endDate&&(this.startDate.isBefore(this.endDate)||this.startDate.isSame(this.endDate))?this.container.find("button.applyBtn").prop("disabled",!1):this.container.find("button.applyBtn").prop("disabled",!0)},move:function(){var t,a={top:0,left:0},i=this.drops,s=e(window).width();switch(this.parentEl.is("body")||(a={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},s=this.parentEl[0].clientWidth+this.parentEl.offset().left),i){case"auto":(t=this.element.offset().top+this.element.outerHeight()-a.top)+this.container.outerHeight()>=this.parentEl[0].scrollHeight&&(t=this.element.offset().top-this.container.outerHeight()-a.top,i="up");break;case"up":t=this.element.offset().top-this.container.outerHeight()-a.top;break;default:t=this.element.offset().top+this.element.outerHeight()-a.top}this.container.css({top:0,left:0,right:"auto"});var n=this.container.outerWidth();if(this.container.toggleClass("drop-up","up"==i),"left"==this.opens){var r=s-this.element.offset().left-this.element.outerWidth();n+r>e(window).width()?this.container.css({top:t,right:"auto",left:9}):this.container.css({top:t,right:r,left:"auto"})}else if("center"==this.opens){(o=this.element.offset().left-a.left+this.element.outerWidth()/2-n/2)<0?this.container.css({top:t,right:"auto",left:9}):o+n>e(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:o,right:"auto"})}else{var o;(o=this.element.offset().left-a.left)+n>e(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:o,right:"auto"})}},show:function(t){this.isShowing||(this._outsideClickProxy=e.proxy((function(t){this.outsideClick(t)}),this),e(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),e(window).on("resize.daterangepicker",e.proxy((function(t){this.move(t)}),this)),this.oldStartDate=this.startDate.clone(),this.oldEndDate=this.endDate.clone(),this.previousRightTime=this.endDate.clone(),this.updateView(),this.container.show(),this.move(),this.element.trigger("show.daterangepicker",this),this.isShowing=!0)},hide:function(t){this.isShowing&&(this.endDate||(this.startDate=this.oldStartDate.clone(),this.endDate=this.oldEndDate.clone()),this.startDate.isSame(this.oldStartDate)&&this.endDate.isSame(this.oldEndDate)||this.callback(this.startDate.clone(),this.endDate.clone(),this.chosenLabel),this.updateElement(),e(document).off(".daterangepicker"),e(window).off(".daterangepicker"),this.container.hide(),this.element.trigger("hide.daterangepicker",this),this.isShowing=!1)},toggle:function(t){this.isShowing?this.hide():this.show()},outsideClick:function(t){var a=e(t.target);"focusin"==t.type||a.closest(this.element).length||a.closest(this.container).length||a.closest(".calendar-table").length||(this.hide(),this.element.trigger("outsideClick.daterangepicker",this))},showCalendars:function(){this.container.addClass("show-calendar"),this.move(),this.element.trigger("showCalendar.daterangepicker",this)},hideCalendars:function(){this.container.removeClass("show-calendar"),this.element.trigger("hideCalendar.daterangepicker",this)},clickRange:function(t){var e=t.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{var a=this.ranges[e];this.startDate=a[0],this.endDate=a[1],this.timePicker||(this.startDate.startOf("day"),this.endDate.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.clickApply()}},clickPrev:function(t){e(t.target).parents(".drp-calendar").hasClass("left")?(this.leftCalendar.month.subtract(1,"month"),this.linkedCalendars&&this.rightCalendar.month.subtract(1,"month")):this.rightCalendar.month.subtract(1,"month"),this.updateCalendars()},clickNext:function(t){e(t.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.month.add(1,"month"):(this.rightCalendar.month.add(1,"month"),this.linkedCalendars&&this.leftCalendar.month.add(1,"month")),this.updateCalendars()},hoverDate:function(t){if(e(t.target).hasClass("available")){var a=e(t.target).attr("data-title"),i=a.substr(1,1),s=a.substr(3,1),n=e(t.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[i][s]:this.rightCalendar.calendar[i][s],r=this.leftCalendar,o=this.rightCalendar,h=this.startDate;this.endDate||this.container.find(".drp-calendar tbody td").each((function(t,a){if(!e(a).hasClass("week")){var i=e(a).attr("data-title"),s=i.substr(1,1),l=i.substr(3,1),c=e(a).parents(".drp-calendar").hasClass("left")?r.calendar[s][l]:o.calendar[s][l];c.isAfter(h)&&c.isBefore(n)||c.isSame(n,"day")?e(a).addClass("in-range"):e(a).removeClass("in-range")}}))}},clickDate:function(t){if(e(t.target).hasClass("available")){var a=e(t.target).attr("data-title"),i=a.substr(1,1),s=a.substr(3,1),n=e(t.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[i][s]:this.rightCalendar.calendar[i][s];if(this.endDate||n.isBefore(this.startDate,"day")){if(this.timePicker){var r=parseInt(this.container.find(".left .hourselect").val(),10);if(!this.timePicker24Hour)"PM"===(l=this.container.find(".left .ampmselect").val())&&r<12&&(r+=12),"AM"===l&&12===r&&(r=0);var o=parseInt(this.container.find(".left .minuteselect").val(),10);isNaN(o)&&(o=parseInt(this.container.find(".left .minuteselect option:last").val(),10));var h=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0;n=n.clone().hour(r).minute(o).second(h)}this.endDate=null,this.setStartDate(n.clone())}else if(!this.endDate&&n.isBefore(this.startDate))this.setEndDate(this.startDate.clone());else{if(this.timePicker){var l;r=parseInt(this.container.find(".right .hourselect").val(),10);if(!this.timePicker24Hour)"PM"===(l=this.container.find(".right .ampmselect").val())&&r<12&&(r+=12),"AM"===l&&12===r&&(r=0);o=parseInt(this.container.find(".right .minuteselect").val(),10);isNaN(o)&&(o=parseInt(this.container.find(".right .minuteselect option:last").val(),10));h=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0;n=n.clone().hour(r).minute(o).second(h)}this.setEndDate(n.clone()),this.autoApply&&(this.calculateChosenLabel(),this.clickApply())}this.singleDatePicker&&(this.setEndDate(this.startDate),!this.timePicker&&this.autoApply&&this.clickApply()),this.updateView(),t.stopPropagation()}},calculateChosenLabel:function(){var t=!0,e=0;for(var a in this.ranges){if(this.timePicker){var i=this.timePickerSeconds?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm";if(this.startDate.format(i)==this.ranges[a][0].format(i)&&this.endDate.format(i)==this.ranges[a][1].format(i)){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").attr("data-range-key");break}}else if(this.startDate.format("YYYY-MM-DD")==this.ranges[a][0].format("YYYY-MM-DD")&&this.endDate.format("YYYY-MM-DD")==this.ranges[a][1].format("YYYY-MM-DD")){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").attr("data-range-key");break}e++}t&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").attr("data-range-key"):this.chosenLabel=null,this.showCalendars())},clickApply:function(t){this.hide(),this.element.trigger("apply.daterangepicker",this)},clickCancel:function(t){this.startDate=this.oldStartDate,this.endDate=this.oldEndDate,this.hide(),this.element.trigger("cancel.daterangepicker",this)},monthOrYearChanged:function(t){var a=e(t.target).closest(".drp-calendar").hasClass("left"),i=a?"left":"right",s=this.container.find(".drp-calendar."+i),n=parseInt(s.find(".monthselect").val(),10),r=s.find(".yearselect").val();a||(rthis.maxDate.year()||r==this.maxDate.year()&&n>this.maxDate.month())&&(n=this.maxDate.month(),r=this.maxDate.year()),a?(this.leftCalendar.month.month(n).year(r),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.clone().add(1,"month"))):(this.rightCalendar.month.month(n).year(r),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.clone().subtract(1,"month"))),this.updateCalendars()},timeChanged:function(t){var a=e(t.target).closest(".drp-calendar"),i=a.hasClass("left"),s=parseInt(a.find(".hourselect").val(),10),n=parseInt(a.find(".minuteselect").val(),10);isNaN(n)&&(n=parseInt(a.find(".minuteselect option:last").val(),10));var r=this.timePickerSeconds?parseInt(a.find(".secondselect").val(),10):0;if(!this.timePicker24Hour){var o=a.find(".ampmselect").val();"PM"===o&&s<12&&(s+=12),"AM"===o&&12===s&&(s=0)}if(i){var h=this.startDate.clone();h.hour(s),h.minute(n),h.second(r),this.setStartDate(h),this.singleDatePicker?this.endDate=this.startDate.clone():this.endDate&&this.endDate.format("YYYY-MM-DD")==h.format("YYYY-MM-DD")&&this.endDate.isBefore(h)&&this.setEndDate(h.clone())}else if(this.endDate){var l=this.endDate.clone();l.hour(s),l.minute(n),l.second(r),this.setEndDate(l)}this.updateCalendars(),this.updateFormInputs(),this.renderTimePicker("left"),this.renderTimePicker("right")},elementChanged:function(){if(this.element.is("input")&&this.element.val().length){var e=this.element.val().split(this.locale.separator),a=null,i=null;2===e.length&&(a=t(e[0],this.locale.format),i=t(e[1],this.locale.format)),(this.singleDatePicker||null===a||null===i)&&(i=a=t(this.element.val(),this.locale.format)),a.isValid()&&i.isValid()&&(this.setStartDate(a),this.setEndDate(i),this.updateView())}},keydown:function(t){9!==t.keyCode&&13!==t.keyCode||this.hide(),27===t.keyCode&&(t.preventDefault(),t.stopPropagation(),this.hide())},updateElement:function(){if(this.element.is("input")&&this.autoUpdateInput){var t=this.startDate.format(this.locale.format);this.singleDatePicker||(t+=this.locale.separator+this.endDate.format(this.locale.format)),t!==this.element.val()&&this.element.val(t).trigger("change")}},remove:function(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}},e.fn.daterangepicker=function(t,i){var s=e.extend(!0,{},e.fn.daterangepicker.defaultOptions,t);return this.each((function(){var t=e(this);t.data("daterangepicker")&&t.data("daterangepicker").remove(),t.data("daterangepicker",new a(t,s,i))})),this},a})); +//# sourceMappingURL=/sm/88e48650a36caa41dd1aa0f1a5ee66247818a496500de85dec44b4e2e87cd438.map \ No newline at end of file diff --git a/tree_view_advanced_filter/static/src/tree_view_advanced_filter/main.scss b/tree_view_advanced_filter/static/src/tree_view_advanced_filter/main.scss new file mode 100644 index 000000000..3506a2d40 --- /dev/null +++ b/tree_view_advanced_filter/static/src/tree_view_advanced_filter/main.scss @@ -0,0 +1,71 @@ +.tree_search_item { + cursor: pointer; +} + + +.tree_search_item .selected a:before { + font-family: FontAwesome; + position: absolute; + left: 10px; + top: 10px; +} + +input.input_text{ + transition: all 0.3s ease; +} + +.search_div{ + display: flex; + align-items: center; + border: 1px solid #1a4040; + font-size: 15px !important; + border-radius: 8px; + text-align: center; + overflow: hidden; + padding: 2px; +} +.input_text{ + flex: 2; + border: none!important; +} +.search_button{ + margin: 0px 0px; + border:none +} +.search_button:hover{ + color: blueviolet; +} +.remove_button{ + border:none +} +.remove_button:hover{ + color: indianred; +} +.hidden_button{ +display:none +} +.table_layout +{ +table-layout:auto +} + +.auto-overflow { + overflow: auto !important; +} + +/* Hide scrollbar for Chrome, Safari and Opera */ +.auto-overflow::-webkit-scrollbar { + display: none; +} + +/* Hide scrollbar for IE, Edge and Firefox */ +.auto-overflow { + -ms-overflow-style: none; + /* IE and Edge */ + scrollbar-width: none; + /* Firefox */ +} + +.min-wp-50 { + min-width: 50px !important; +} \ No newline at end of file diff --git a/tree_view_advanced_filter/static/src/tree_view_advanced_filter/search_model.js b/tree_view_advanced_filter/static/src/tree_view_advanced_filter/search_model.js new file mode 100644 index 000000000..c51f33a8c --- /dev/null +++ b/tree_view_advanced_filter/static/src/tree_view_advanced_filter/search_model.js @@ -0,0 +1,13 @@ +// /** @odoo-module */ + +import { SearchModel } from "@web/search/search_model"; +import { patch } from "@web/core/utils/patch"; + +patch(SearchModel.prototype, { + async _reloadSections() { + super._reloadSections(...arguments); + if (this.ak_domains) { + this._domain = this.domain.concat(this.ak_domains); + } + }, +}); diff --git a/tree_view_advanced_filter/static/src/tree_view_advanced_filter/tree.js b/tree_view_advanced_filter/static/src/tree_view_advanced_filter/tree.js new file mode 100644 index 000000000..a63450689 --- /dev/null +++ b/tree_view_advanced_filter/static/src/tree_view_advanced_filter/tree.js @@ -0,0 +1,605 @@ +/** @odoo-module */ + +import { ListRenderer } from "@web/views/list/list_renderer"; +import { browser } from "@web/core/browser/browser"; +import { patch } from "@web/core/utils/patch"; +import { session } from "@web/session"; +import { serialize } from "@web/core/l10n/dates"; +import { serializeDateTime } from "@web/core/l10n/dates"; +import { loadJS, loadCSS } from "@web/core/assets"; +const { onMounted, onPatched } = owl; +const { DateTime } = luxon; + +export const ListRendererCust = { + setup() { + + super.setup(); + browser.sessionStorage.setItem('domainlist', JSON.stringify([])); // Replaced localStorage with sessionStorage + + onMounted(() => { + this._renderSearchPanel() + }); + + onPatched(() => { + this._renderSearchPanel() + }); + }, + + _renderSearchPanel: async function () { + // await loadJS("https://cdn.jsdelivr.net/jquery/latest/jquery.min.js") + // await loadJS("https://cdn.jsdelivr.net/momentjs/latest/moment.min.js") + // await loadJS("https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js") + // await loadCSS("https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css") + // await loadJS("/tree_view_advanced_filter/static/src/libs/jquery.min.js"); + await loadJS("/tree_view_advanced_filter/static/src/libs/daterangepicker.min.js"); + await loadCSS("/tree_view_advanced_filter/static/src/libs/daterangepicker.css"); + await loadJS("/tree_view_advanced_filter/static/src/libs/moment/moment.min.js"); + var List = this.props.list; + const bm_params = List.model.__bm_load_params__; + const rootRef = this.rootRef.el + const tableRef = this.tableRef.el; + tableRef.removeAttribute('style') + var columns = this.allColumns.filter((col) => { + if (col.optional && this.optionalActiveFields[col.name] == false) { + return false; + } + if (col.column_invisible == true || col.column_invisible && col.invisible) { + return false; + } +// if (col.optional == 'hide'){ +// return false; +// } + if (['in_invoice', 'in_refund', 'in_receipt'].includes(this.props.list.evalContext.default_move_type)){ + if (['Vendor', 'Invoice Date'].includes(col.string)) { + return false; + } + } + if (['out_invoice', 'out_refund', 'out_receipt'].includes(this.props.list.evalContext.default_move_type)){ + if (['Customer', 'Bill Date'].includes(col.string)) { + return false; + } + } + if (col.name == 'move_type'){ + return false; + } + return true; + }); + + var $tr1 = $('').append(columns.map(columns => this._renderHeaderCellSearch(columns))); + // 添加行号占位td + $tr1.prepend($('').addClass('web_list_num')); + if (this.hasSelectors) { + $tr1.prepend($('').addClass('o_list_record_selector')); + } + + if (this.isStudioEditable || this.displayOptionalFields) { + $tr1.append($('').addClass('o_list_record_selector')); + } + + if ($(tableRef).find('.search_td').length) { + $(tableRef).find('.search_td').parent().replaceWith($tr1) + } + else { + $tr1.insertAfter($(tableRef).find('tr')[0]); + } + + rootRef.querySelectorAll('thead tr td.search_td input').forEach((a) => a.addEventListener('keyup', this._onfilter.bind(this))); + rootRef.querySelectorAll('.search_button').forEach((a) => a.addEventListener('click', this._onSearch.bind(this))); + rootRef.querySelectorAll('.remove_button').forEach((a) => a.addEventListener('click', this._onRemove.bind(this))); + rootRef.querySelectorAll('thead tr td').forEach((a) => a.addEventListener('keypress', this._onKeyPress.bind(this))); + }, + + _renderHeaderCellSearch: function (node) { + var List = this.props.list + var search_tr = $($('tr')[1]).find('input.input_text') + var old_domain = JSON.parse(browser.sessionStorage.getItem('domainlist')) + var input_dict = {} + var self = this; + var $td = $('', { + class: 'search_td' + }); + + for (var i = 0; i < search_tr.length; i++) { + var field = $(search_tr[i]).attr('name') + var value = $(search_tr[i]).val() + input_dict[String(field)] = value + } + if (node.type != 'field') { + return $td + } + const { + name, + string, + widget, + } = node; + var searched_value = old_domain.filter(function (domain) { + return domain[0] == name; + }); + var widget_list = ["monetary", "date", "many2one_avatar_user", "badge", "task_with_hours", "timesheet_uom", "sol_product_many2one"]; + var value_of_tr = searched_value.length > 0 ? searched_value[0][2] : "" + var field = List.fields[name]; + + if (name) { + $td.attr('data-name', name); + } else if (string) { + $td.attr('data-string', string); + } + if (!field) { + return $td; + } + var description = string || field.string; + + // search elements + var search_div = $('
').attr({ + 'class': 'search_div d-inline-flex auto-overflow' + }); + var $input = $('').attr({ + name: name, + data_name: name, + data_text: string, + placeholder: description, + autocomplete: "autocomplete", + 'class': 'input_text min-wp-50' + }); + var search_button = $('