This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
162 additions
and
179 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
========================================== | ||
Product - Search On Complete Category Name | ||
========================================== | ||
|
||
Search the product_category on the complete name, that's to say the | ||
name containing all parents | ||
|
||
Contributors | ||
------------ | ||
|
||
* Julien WESTE | ||
* Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
|
||
Funders | ||
------- | ||
|
||
The development of this module has been financially supported by: | ||
|
||
* GRAP, Groupement Régional Alimentaire de Proximité (http://www.grap.coop) |
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 |
---|---|---|
@@ -1,24 +1,2 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Product - Search On Complete Category Name Module for Odoo | ||
# Copyright (C) 2013-Today GRAP (http://www.grap.coop) | ||
# @author Julien WESTE | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
|
||
from . import model | ||
# coding: utf-8 | ||
from . import models |
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 |
---|---|---|
@@ -1,48 +1,23 @@ | ||
# -*- encoding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Product - Search On Complete Category Name Module for Odoo | ||
# Copyright (C) 2013-Today GRAP (http://www.grap.coop) | ||
# @author Julien WESTE | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
# coding: utf-8 | ||
# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) | ||
# @author: Julien WESTE | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
'name': 'Product - Search On Complete Category Name', | ||
'version': '0.2', | ||
'version': '8.0.1.0.0', | ||
'category': 'Product', | ||
'description': """ | ||
Search the product_category on the complete name, that's to say the | ||
name containing all parents | ||
=================================================================== | ||
=========================== | ||
Copyright, Author and Licence : | ||
------------------------------- | ||
* Copyright : 2013, Groupement Régional Alimentaire de Proximité; | ||
* Author : | ||
* Julien WESTE; | ||
* Licence : AGPL-3 (http://www.gnu.org/licenses/) | ||
""", | ||
'author': 'GRAP', | ||
'website': 'http://www.grap.coop', | ||
'license': 'AGPL-3', | ||
'depends': [ | ||
'product', | ||
], | ||
'data': [ | ||
'view/product_view.xml', | ||
'views/view_product_category.xml', | ||
], | ||
'demo': [ | ||
'demo/res_groups.xml', | ||
'demo/product_category.xml', | ||
], | ||
} |
18 changes: 18 additions & 0 deletions
18
product_categ_search_complete_name/demo/product_category.xml
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<openerp><data> | ||
|
||
<record id="category_parent" model="product.category"> | ||
<field name="name">Parent Category</field> | ||
</record> | ||
|
||
<record id="category_child" model="product.category"> | ||
<field name="name">Child Category</field> | ||
<field name="parent_id" ref="category_parent"/> | ||
</record> | ||
|
||
</data></openerp> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<openerp><data> | ||
|
||
<record id="base.group_sale_manager" model="res.groups"> | ||
<field name="users" eval="[(4, ref('base.user_root'))]"/> | ||
</record> | ||
|
||
<record id="base.group_no_one" model="res.groups"> | ||
<field name="users" eval="[(4, ref('base.user_root'))]"/> | ||
</record> | ||
|
||
</data></openerp> |
This file was deleted.
Oops, something went wrong.
80 changes: 0 additions & 80 deletions
80
product_categ_search_complete_name/model/product_category.py
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
# coding: utf-8 | ||
from . import product_category |
36 changes: 36 additions & 0 deletions
36
product_categ_search_complete_name/models/product_category.py
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,36 @@ | ||
# coding: utf-8 | ||
# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) | ||
# @author: Julien WESTE | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
from openerp import api, fields, models | ||
|
||
|
||
class ProductCategory(models.Model): | ||
_inherit = 'product.category' | ||
_rec_name = 'stored_complete_name' | ||
|
||
# Columns section | ||
stored_complete_name = fields.Char( | ||
string='Stored Complete Name', store=True, | ||
compute='_compute_stored_complete_name') | ||
|
||
# compute Section | ||
@api.multi | ||
@api.depends('name', 'parent_id.stored_complete_name') | ||
def _compute_stored_complete_name(self): | ||
for category in self: | ||
if not category.parent_id: | ||
category.stored_complete_name = category.name | ||
else: | ||
category.stored_complete_name = "%s / %s" % ( | ||
category.parent_id.stored_complete_name, category.name) | ||
|
||
@api.model | ||
def name_search(self, name='', args=None, operator='ilike', limit=100): | ||
res = self.search( | ||
[('stored_complete_name', operator, name)] + (args or []), | ||
limit=limit) | ||
return res.name_get() |
Binary file not shown.
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,2 @@ | ||
# coding: utf-8 | ||
from . import test_module |
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,37 @@ | ||
# coding: utf-8 | ||
# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp.tests.common import TransactionCase | ||
|
||
|
||
class TestModule(TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestModule, self).setUp() | ||
self.ProductCategory = self.env['product.category'] | ||
self.category_parent = self.env.ref( | ||
'product_categ_search_complete_name.category_parent') | ||
self.category_child = self.env.ref( | ||
'product_categ_search_complete_name.category_child') | ||
|
||
# Test Section | ||
def test_01_search_category_complete(self): | ||
res = self.ProductCategory.name_search( | ||
self.category_child.complete_name) | ||
|
||
self.assertEqual( | ||
len(res) == 1 and res[0][0], | ||
self.category_child.id, | ||
"Searching on complete name should succeed") | ||
|
||
# Test Section | ||
def test_02_search_category_partial(self): | ||
res = self.ProductCategory.name_search( | ||
"%s /" % self.category_parent.name) | ||
|
||
self.assertEqual( | ||
len(res) == 1 and res[0][0], | ||
self.category_child.id, | ||
"Searching on the name of the parent plus / should succeed") |
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
product_categ_search_complete_name/views/view_product_category.xml
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp><data> | ||
|
||
<record id="view_product_category_search" model="ir.ui.view"> | ||
<field name="model">product.category</field> | ||
<field name="inherit_id" ref="product.product_category_search_view" /> | ||
<field name="arch" type="xml"> | ||
<field name="name" position="after"> | ||
<field name="stored_complete_name" string="Complete Name" /> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</data></openerp> |