Browse Source

[FIX] Bug Fixed 'master_search'

pull/277/head
AjmalCybro 2 years ago
parent
commit
8472fe290e
  1. 4
      master_search/__manifest__.py
  2. 7
      master_search/doc/RELEASE_NOTES.md
  3. 5
      master_search/models/master_search.py
  4. 340
      master_search/views/master_search_view.xml

4
master_search/__manifest__.py

@ -21,7 +21,7 @@
{
'name': 'Global Search',
'version': '16.0.1.0.0',
'version': '16.0.1.0.1',
'summary': """Easy Search in Customers, Products, Sale, Purchase, Inventory and Accounting modules""",
'description': """Search, Global Search, Quick Search, Easy Search, Easy Search in Customers, Products, Sale, Purchase, Inventory and Accounting modules,
Search, Advance search, global search, odoo16, """,
@ -40,7 +40,7 @@
],
'assets': {
'web.assets_backend': [
'master_search/static/src/scss/master_search.scss'
'master_search/static/src/scss/master_search.scss',
],
},
'installable': True,

7
master_search/doc/RELEASE_NOTES.md

@ -3,5 +3,10 @@
#### 09.11.2022
#### Version 16.0.1.0.0
#### ADD
Initial Commit
- Initial Commit
#### 03.08.2023
#### Version 16.0.1.0.1
#### BUGFIX
- Report Bug Fix: Issue while expanding the tree view in form view

5
master_search/models/master_search.py

@ -134,7 +134,6 @@ class MasterSearch(models.Model):
def _get_operator_count(self):
""" Get customer count """
self.customer_count = len(self.customer_ids)
print(self.customer_count)
@api.depends('transaction_count')
def _get_transaction_count(self):
@ -190,13 +189,11 @@ class MasterSearch(models.Model):
# search for all the words
for key in search_keys:
search_vals = self._search_query(key)
print('search valss', search_vals)
self.name = self.search_string
def _search_query(self, key):
""" search for the model with given key and update result """
print('help')
company_id = self.env.user.company_id.id
if self.search_mode == 'all':
active_qry = """
@ -338,7 +335,6 @@ class MasterSearch(models.Model):
transactions = self._cr.dictfetchall()
transaction_ids = self.env['stock.picking'].browse(
[i['id'] for i in transactions])
print(self.transaction_details)
self.transaction_details += transaction_ids
def _search_products(self, key, active_qry, company_id):
@ -370,7 +366,6 @@ class MasterSearch(models.Model):
product_template_ids = self.env['product.template'].browse(
[i['id'] for i in template_ids])
self.product_ids += product_template_ids
print('2',product_template_ids)
def _search_customer(self, key, active_qry):
""" search for customer """

340
master_search/views/master_search_view.xml

@ -12,128 +12,129 @@
</style>
<script>
$(document).ready(function(){
$(".disable_open").unbind("click");
if ($(".oe_search_bgnd").length > 0){document.title = 'Search';}
$("#recent_searches").click(function(){
event.target.parentElement.children[1].classList.toggle('oe_details_tree--show');
});
$("#customer_search_results").click(function(){
event.target.parentElement.children[1].classList.toggle('oe_details_tree--show');
});
$("#product_search_results").click(function(){
event.target.parentElement.children[1].classList.toggle('oe_details_tree--show');
});
$("#inventory_search_results").click(function(){
event.target.parentElement.children[1].classList.toggle('oe_details_tree--show');
});
$("#sale_search_results").click(function(){
event.target.parentElement.children[1].classList.toggle('oe_details_tree--show');
});
$("#purchase_search_results").click(function(){
event.target.parentElement.children[1].classList.toggle('oe_details_tree--show');
});
$("#accounting_search_results").click(function(){
event.target.parentElement.children[1].classList.toggle('oe_details_tree--show');
});
$('.o_radio_input').on('change', function(){
let targetEl = $(this).data().value;
$('.oe_details_tree').addClass('d-none');
$('.oe_details_tree').removeClass('oe_details_tree--show');
switch(targetEl){
case 'customer':
$(".disable_open").unbind("click");
if ($(".oe_search_bgnd").length > 0){document.title =
'Search';}
function toggleDetailsTree($target) {
var element =
$target.closest('.oe_result_div').find('.oe_details_tree');
element.toggleClass('oe_details_tree--show');
}
$(document).on("click", ".expand_tile", function(event)
{
var $target = $(event.target);
if ($target.hasClass('expand_tile')) {
toggleDetailsTree($target);
} else if ($target.hasClass('history')) {
toggleDetailsTree($target);
} else if ($target.hasClass('dropdown')) {
toggleDetailsTree($target);
}
});
$('.o_radio_input').on('change', function(){
let targetEl = $(this).data().value;
$('.oe_details_tree').addClass('d-none');
$('.oe_details_tree').removeClass('oe_details_tree--show');
switch(targetEl){
case 'customer':
$('.oe_search_tab').addClass('d-none');
$('#customer_search_results').addClass('d-block');
$('#customer_search_results').removeClass('d-none');
$('.oe_search_tab').addClass('d-none');
$('#customer_search_results').addClass('d-block');
$('#customer_search_results').removeClass('d-none');
break;
break;
case 'product':
case 'product':
$('.oe_search_tab').addClass('d-none');
$('#product_search_results').addClass('d-block');
$('#product_search_results').removeClass('d-none');
$('.oe_search_tab').addClass('d-none');
$('#product_search_results').addClass('d-block');
$('#product_search_results').removeClass('d-none');
break;
break;
case 'transaction details':
case 'transaction details':
$('.oe_search_tab').addClass('d-none');
$('#inventory_search_results').addClass('d-block');
$('#inventory_search_results').removeClass('d-none');
$('.oe_search_tab').addClass('d-none');
$('#inventory_search_results').addClass('d-block');
$('#inventory_search_results').removeClass('d-none');
break;
break;
case 'sale details':
case 'sale details':
$('.oe_search_tab').addClass('d-none');
$('#sale_search_results').addClass('d-block');
$('#sale_search_results').removeClass('d-none');
$('.oe_search_tab').addClass('d-none');
$('#sale_search_results').addClass('d-block');
$('#sale_search_results').removeClass('d-none');
break;
break;
case 'purchase details':
case 'purchase details':
$('.oe_search_tab').addClass('d-none');
$('#purchase_search_results').addClass('d-block');
$('#purchase_search_results').removeClass('d-none');
$('.oe_search_tab').addClass('d-none');
$('#purchase_search_results').addClass('d-block');
$('#purchase_search_results').removeClass('d-none');
break;
break;
case 'account details':
case 'account details':
$('.oe_search_tab').addClass('d-none');
$('#accounting_search_results').addClass('d-block');
$('#accounting_search_results').removeClass('d-none');
$('.oe_search_tab').addClass('d-none');
$('#accounting_search_results').addClass('d-block');
$('#accounting_search_results').removeClass('d-none');
break;
break;
case 'any':
$('.oe_search_tab').removeClass('d-none');
break;
}
$('#recent_searches').addClass('d-block');
$('#recent_searches').removeClass('d-none');
})
case 'any':
$('.oe_search_tab').removeClass('d-none');
break;
}
$('#recent_searches').addClass('d-block');
$('#recent_searches').removeClass('d-none');
})
});
</script>
<sheet>
<div class="row oe_search_bgnd"
style="padding: 24px 32px;background-color:#e5e4f9;border-radius: 5px;">
<div class="col-12 col-md-8 col-xl-8">
<label for="search_string" string="Search " style="display: inline-block;"
<label for="search_string" string="Search "
style="display: inline-block;"
class="oe_read_only"/>
<field name="search_string" default_focus="1" class="search_input"
<field name="search_string" default_focus="1"
class="search_input"
style="width: 80%; display: inline-block;margin-right: 0px;block-size: 32px;"
placeholder="Type here to search.."/>
<button name="action_clear_search"
type="object" title="Search" class="fa fa-times oe_edit_only btn_master_search"/>
type="object" title="Search"
class="fa fa-times oe_edit_only btn_master_search"/>
<button name="action_search"
type="object"
title="Search"
class="fa fa-search oe_search_btn btn_master_search oe_edit_only"/>
<div class="not-allowed">Regular expressions are not allowed in search!</div>
<div class="not-allowed">Regular expressions are
not allowed in search!
</div>
<div>
<label for="match_entire" string="Match Phrase :" style="display: inline-block;"/>
<field name="match_entire" style="display: inline-block; margin-left: 10px;"/>
<label for="match_entire"
string="Match Phrase :"
style="display: inline-block;"/>
<field name="match_entire"
style="display: inline-block; margin-left: 10px;"/>
</div>
<div style="display: block;">
<label for="search_by" string="Search For :" class="oe_read_only"/>
<field name="search_by" widget="radio" options="{'horizontal': true}"/>
<label for="search_by" string="Search For :"
class="oe_read_only"/>
<field name="search_by" widget="radio"
options="{'horizontal': true}"/>
</div>
</div>
<div class="col-12 col-md-4 col-xl-4">
<div style="display: block;">
<label for="search_mode" string="Mode :" class="oe_read_only"/>
<field name="search_mode" widget="radio" nolabel="1"
<label for="search_mode" string="Mode :"
class="oe_read_only"/>
<field name="search_mode" widget="radio"
nolabel="1"
options="{'horizontal': false}"/>
</div>
</div>
@ -142,46 +143,60 @@
<div class="oe_result_div">
<div id="recent_searches" style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
margin-top: 10px; border-top-right-radius: 5px;border-top-left-radius: 5px;"
class="oe_search_tab" >
class="oe_search_tab expand_tile">
Recent Searches
<div style="float: right;">
<field name="history_count" class="oe_tab_count" readonly="1"/>
<div class="history" style="float: right;">
<field name="history_count"
class="oe_tab_count" readonly="1"/>
Records Found
<span class="oe_drop_down">
<i style="color: #fff !important; font-size: 16px;" title="Search" class="fa fa-caret-down"
/>
<i style="color: #fff !important; font-size: 16px;"
title="Search"
class="fa fa-caret-down dropdown"
/>
</span>
</div>
</div>
<div style="height: 200px; overflow-y: scroll;width: 100%;" class="oe_details_tree">
<div style="height: 200px; overflow-y: scroll;width: 100%;"
class="oe_details_tree">
<field name="master_search_ids">
<tree create="0" class="disable_open">
<field name="search_string" class="re_search oe_key"/>
<field name="search_mode" string="Mode" class="re_search"/>
<field name="search_by" string="Type" class="re_search"/>
<field name="search_string"
class="re_search oe_key"/>
<field name="search_mode" string="Mode"
class="re_search"/>
<field name="search_by" string="Type"
class="re_search"/>
<!--<field name="create_date" string="Date" optional="hide" class="re_search"/>-->
<button style="display: inline-block;" name="action_unlink_search"
title="Search" type="object" class="fa fa-trash"/>
<button style="display: inline-block;"
name="action_unlink_search"
title="Search" type="object"
class="fa fa-trash"/>
</tree>
</field>
</div>
</div>
<div class="oe_result_div">
<div id="customer_search_results" style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
<div id="customer_search_results"
style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
margin-top: 10px; border-top-right-radius: 5px;border-top-left-radius: 5px;"
class="oe_search_tab accordion_tab">
class="oe_search_tab accordion_tab expand_tile">
Customer Search Results
<div style="float: right;">
<field name="customer_count" class="oe_tab_count" readonly="1"/>
<div class="history" style="float: right;">
<field name="customer_count"
class="oe_tab_count" readonly="1"/>
Records Found
<span class="oe_drop_down">
<i style="color: #fff !important; font-size: 16px;" title="Search" class="fa fa-caret-down"
<i style="color: #fff !important; font-size: 16px;"
title="Search"
class="fa fa-caret-down dropdown"
/>
</span>
</div>
</div>
<div style="height: 200px; overflow-y: scroll;width: 100%;" class="oe_details_tree">
<div style="height: 200px; overflow-y: scroll;width: 100%;"
class="oe_details_tree">
<field name="customer_ids">
<tree create="0" delete="0">
<field name="name" string="Name"/>
@ -193,27 +208,37 @@
<div class="oe_result_div">
<div id="product_search_results" style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
margin-top: 10px; border-top-right-radius: 5px;border-top-left-radius: 5px;"
class="oe_search_tab accordion_tab">
class="oe_search_tab accordion_tab expand_tile">
Product Search Results
<div style="float: right;">
<field name="product_count" class="oe_tab_count" readonly="1"/>
<div class="history" style="float: right;">
<field name="product_count"
class="oe_tab_count" readonly="1"/>
Records Found
<span class="oe_drop_down">
<i style="color: #fff !important; font-size: 16px;" title="Search" class="fa fa-caret-down"/>
<i style="color: #fff !important; font-size: 16px;"
title="Search"
class="fa fa-caret-down dropdown"/>
</span>
</div>
</div>
<div style="height: 200px; overflow-y: scroll;width: 100%;" class="oe_details_tree"
<div style="height: 200px; overflow-y: scroll;width: 100%;"
class="oe_details_tree"
name="products">
<field name="product_ids">
<tree create="0" delete="0">
<field name="name" string="Name"/>
<field name="default_code" string="Code"/>
<field name="description" string="Description"/>
<field name="type" string="Product Type"/>
<field name="categ_id" string="Category"/>
<field name="uom_id" string="Base UoM" optional="hide"/>
<field name="qty_available" string="Stock"/>
<field name="default_code"
string="Code"/>
<field name="description"
string="Description"/>
<field name="type"
string="Product Type"/>
<field name="categ_id"
string="Category"/>
<field name="uom_id" string="Base UoM"
optional="hide"/>
<field name="qty_available"
string="Stock"/>
</tree>
</field>
</div>
@ -221,25 +246,33 @@
<div class="oe_result_div">
<div id="inventory_search_results" style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
margin-top: 10px; border-top-right-radius: 5px;border-top-left-radius: 5px;"
class="oe_search_tab accordion_tab">
class="oe_search_tab accordion_tab expand_tile">
Inventory Search Results
<div style="float: right;">
<field name="transaction_count" class="oe_tab_count" readonly="1"/>
<div class="history" style="float: right;">
<field name="transaction_count"
class="oe_tab_count" readonly="1"/>
Records Found
<span class="oe_drop_down">
<i style="color: #fff !important; font-size: 16px;" title="Search" class="fa fa-caret-down"/>
<i style="color: #fff !important; font-size: 16px;"
title="Search"
class="fa fa-caret-down dropdown"/>
</span>
</div>
</div>
<div style="height: 200px; overflow-y: scroll;width: 100%;" class="oe_details_tree">
<div style="height: 200px; overflow-y: scroll;width: 100%;"
class="oe_details_tree">
<field name="transaction_details">
<tree create="0" delete="0">
<field name="name" string="Trans. # "/>
<field name="date_done" string="Transaction Date"/>
<field name="picking_type_id" string="Transaction Type"/>
<field name="partner_id" string="Reference Name"/>
<field name="state" string="Transaction Status"/>
<field name="date_done"
string="Transaction Date"/>
<field name="picking_type_id"
string="Transaction Type"/>
<field name="partner_id"
string="Reference Name"/>
<field name="state"
string="Transaction Status"/>
</tree>
</field>
</div>
@ -247,24 +280,31 @@
<div class="oe_result_div">
<div id="sale_search_results" style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
margin-top: 10px; border-top-right-radius: 5px;border-top-left-radius: 5px;"
class="oe_search_tab accordion_tab">
class="oe_search_tab accordion_tab expand_tile">
Sale Search Results
<div style="float: right;">
<field name="sale_count" class="oe_tab_count" readonly="1"/>
<div class="history" style="float: right;">
<field name="sale_count"
class="oe_tab_count" readonly="1"/>
Records Found
<span class="oe_drop_down">
<i style="color: #fff !important; font-size: 16px;" title="Search" class="fa fa-caret-down"/>
<i style="color: #fff !important; font-size: 16px;"
title="Search"
class="fa fa-caret-down dropdown"/>
</span>
</div>
</div>
<div style="height: 200px; overflow-y: scroll;width: 100%;" class="oe_details_tree">
<div style="height: 200px; overflow-y: scroll;width: 100%;"
class="oe_details_tree">
<field name="sale_details">
<tree create="0" delete="0">
<field name="name" string="Trans. # "/>
<field name="partner_id" string="Customer"/>
<field name="pricelist_id" string="Pricelist"/>
<field name="payment_term_id" string="Payment Term"/>
<field name="partner_id"
string="Customer"/>
<field name="pricelist_id"
string="Pricelist"/>
<field name="payment_term_id"
string="Payment Term"/>
<field name="state" string="Status"/>
</tree>
</field>
@ -273,22 +313,27 @@
<div class="oe_result_div">
<div id="purchase_search_results" style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
margin-top: 10px; border-top-right-radius: 5px;border-top-left-radius: 5px;"
class="oe_search_tab accordion_tab">
class="oe_search_tab accordion_tab expand_tile">
Purchase Search Results
<div style="float: right;">
<field name="purchase_count" class="oe_tab_count" readonly="1"/>
<div class="history" style="float: right;">
<field name="purchase_count"
class="oe_tab_count" readonly="1"/>
Records Found
<span class="oe_drop_down">
<i style="color: #fff !important; font-size: 16px;" title="Search" class="fa fa-caret-down"/>
<i style="color: #fff !important; font-size: 16px;"
title="Search"
class="fa fa-caret-down dropdown"/>
</span>
</div>
</div>
<div style="height: 200px; overflow-y: scroll;width: 100%;" class="oe_details_tree">
<div style="height: 200px; overflow-y: scroll;width: 100%;"
class="oe_details_tree">
<field name="purchase_details">
<tree create="0" delete="0">
<field name="name" string="Trans. # "/>
<field name="partner_id" string="Customer"/>
<field name="partner_id"
string="Customer"/>
<field name="state" string="Status"/>
</tree>
</field>
@ -297,22 +342,28 @@
<div class="oe_result_div">
<div id="accounting_search_results" style="background-color: #5f5e97; color: #fff; width: 100%; padding: 5px 10px;
margin-top: 10px; border-top-right-radius: 5px;border-top-left-radius: 5px;"
class="oe_search_tab accordion_tab">
class="oe_search_tab accordion_tab expand_tile">
Accounting Search Results
<div style="float: right;">
<field name="account_count" class="oe_tab_count" readonly="1"/>
<div class="history" style="float: right;">
<field name="account_count"
class="oe_tab_count" readonly="1"/>
Records Found
<span class="oe_drop_down">
<i style="color: #fff !important; font-size: 16px;" title="Search" class="fa fa-caret-down"/>
<i style="color: #fff !important; font-size: 16px;"
title="Search"
class="fa fa-caret-down dropdown"/>
</span>
</div>
</div>
<div style="height: 200px; overflow-y: scroll;width: 100%;" class="oe_details_tree">
<div style="height: 200px; overflow-y: scroll;width: 100%;"
class="oe_details_tree">
<field name="account_details">
<tree create="false" delete="false" edit="false">
<tree create="false" delete="false"
edit="false">
<field name="name" string="Trans. # "/>
<field name="partner_id" string="Customer"/>
<field name="partner_id"
string="Customer"/>
<field name="state" string="Status"/>
</tree>
</field>
@ -329,11 +380,14 @@
<field name="name">Search</field>
<field name="res_model">master.search</field>
<field name="view_mode">form</field>
<field name="context">{'active_test': False, 'search_default_filter_active': 1}</field>
<field name="context">{'active_test': False,
'search_default_filter_active': 1}
</field>
</record>
<!-- Search root menu -->
<menuitem id="master_search_root" name="Search" action="master_search_action"
<menuitem id="master_search_root" name="Search"
action="master_search_action"
web_icon="master_search,static/description/icon.png"
sequence="2" groups="master_search.master_search_read"/>
</data>

Loading…
Cancel
Save