-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] website_sale_ux: allow to disable categories on shop search
closes #249 Signed-off-by: Juan Ignacio Rivero <jr@adhoc.com.ar>
- Loading branch information
1 parent
260efaf
commit 2764bce
Showing
5 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
############################################################################## | ||
# For copyright and license notices, see __manifest__.py file in module root | ||
# directory | ||
############################################################################## | ||
from odoo import models, tools, fields | ||
|
||
|
||
class Website(models.Model): | ||
|
||
_inherit = "website" | ||
|
||
disable_categories_search = fields.Boolean() | ||
|
||
def _search_get_details(self, search_type, order, options): | ||
res = super(Website, self)._search_get_details(search_type, order, options) | ||
if search_type == 'products' and self.sudo()._get_disable_categories_search(): | ||
# borrar el elemento no es lo más elegante pero no vi otra forma facil | ||
# de heredar. no es caro en temas de performance ya que el metodo super | ||
# es super liviano (no hace busquedas ni nada) | ||
for idx, item in enumerate(res): | ||
if item.get('model') == 'product.public.category': | ||
res.pop(idx) | ||
return res | ||
|
||
@tools.ormcache('self.id') | ||
def _get_disable_categories_search(self): | ||
self.ensure_one() | ||
return self.disable_categories_search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters