Skip to content

Commit

Permalink
Merge branch 'thesaurus_imp' into 8.0.4-next-release refs #15909
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Nemry (ACSONE) committed Nov 16, 2015
2 parents 1f9d18a + beac713 commit a7d41a0
Show file tree
Hide file tree
Showing 18 changed files with 897 additions and 429 deletions.
34 changes: 33 additions & 1 deletion mozaik_communication/virtual_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def get_partner_action(self):
class virtual_target(orm.Model):
_name = "virtual.target"
_description = "Searching Result"
_inherit = ['virtual.master.partner', 'abstract.virtual.target']
_inherit = [
'virtual.master.partner',
'abstract.virtual.target',
'abstract.term.finder'
]
_auto = False

_columns = {
Expand Down Expand Up @@ -99,6 +103,7 @@ class virtual_partner_involvement(orm.Model):

_name = "virtual.partner.involvement"
_inherit = "abstract.virtual.target"
_terms = ['interests_m2m_ids', 'competencies_m2m_ids']
_description = "Partner/Involvement"
_auto = False

Expand Down Expand Up @@ -205,6 +210,7 @@ class virtual_partner_relation(orm.Model):
_name = "virtual.partner.relation"
_description = "Partner/Relation"
_inherit = "abstract.virtual.target"
_terms = ['interests_m2m_ids', 'competencies_m2m_ids']
_auto = False

_columns = {
Expand Down Expand Up @@ -349,6 +355,7 @@ class virtual_partner_instance(orm.Model):
_name = "virtual.partner.instance"
_description = "Partner/Instance"
_inherit = "abstract.virtual.target"
_terms = ['interests_m2m_ids', 'competencies_m2m_ids']
_auto = False

_columns = {
Expand Down Expand Up @@ -461,6 +468,11 @@ class virtual_partner_mandate(orm.Model):
_name = "virtual.partner.mandate"
_description = "Partner/Mandate"
_inherit = "abstract.virtual.target"
_terms = [
'ref_partner_competencies_m2m_ids',
'sta_competencies_m2m_ids',
'ext_competencies_m2m_ids'
]
_auto = False

_columns = {
Expand Down Expand Up @@ -664,6 +676,10 @@ class virtual_partner_candidature(orm.Model):
_name = "virtual.partner.candidature"
_description = "Partner/Candidature"
_inherit = "abstract.virtual.target"
_terms = [
'competencies_m2m_ids',
'interests_m2m_ids',
]
_auto = False

_columns = {
Expand Down Expand Up @@ -804,6 +820,10 @@ class virtual_assembly_instance(orm.Model):
_name = "virtual.assembly.instance"
_description = "Assembly/Instance"
_inherit = "abstract.virtual.target"
_terms = [
'competencies_m2m_ids',
'interests_m2m_ids',
]
_auto = False

_columns = {
Expand Down Expand Up @@ -959,6 +979,10 @@ class virtual_partner_retrocession(orm.Model):
_name = "virtual.partner.retrocession"
_description = "Partner/Retrocession"
_inherit = "abstract.virtual.target"
_terms = [
'competencies_m2m_ids',
'interests_m2m_ids',
]
_auto = False

_columns = {
Expand Down Expand Up @@ -1180,6 +1204,10 @@ class virtual_partner_membership(orm.Model):
_name = "virtual.partner.membership"
_description = "Partner/Membership"
_inherit = "abstract.virtual.target"
_terms = [
'competencies_m2m_ids',
'interests_m2m_ids',
]
_auto = False

_columns = {
Expand Down Expand Up @@ -1280,6 +1308,10 @@ class virtual_partner_event(orm.Model):
_name = "virtual.partner.event"
_description = "Partner/Event"
_inherit = "abstract.virtual.target"
_terms = [
'competencies_m2m_ids',
'interests_m2m_ids',
]
_auto = False

_columns = {
Expand Down
3 changes: 2 additions & 1 deletion mozaik_membership/membership_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
class membership_request(orm.Model):

_name = 'membership.request'
_inherit = ['mozaik.abstract.model']
_inherit = ['mozaik.abstract.model', 'abstract.term.finder']
_description = 'Membership Request'
_inactive_cascade = True
_terms = ['interests_m2m_ids', 'competencies_m2m_ids']

@api.multi
@api.constrains('birth_date', 'age', 'state')
Expand Down
4 changes: 3 additions & 1 deletion mozaik_person/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@

class ResPartner(models.Model):

_inherit = 'res.partner'
_name = 'res.partner'
_inherit = ['res.partner', 'abstract.term.finder']
_terms = ['interests_m2m_ids', 'competencies_m2m_ids']

@api.one
@api.depends('select_name')
Expand Down
27 changes: 2 additions & 25 deletions mozaik_thesaurus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of mozaik_thesaurus, an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# mozaik_thesaurus 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.
#
# mozaik_thesaurus 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 mozaik_thesaurus.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import thesaurus
from . import models
from . import wizard
19 changes: 7 additions & 12 deletions mozaik_thesaurus/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
##############################################################################
{
'name': 'MOZAIK: Thesaurus',
'version': '1.0',
"author": "ACSONE SA/NV",
"maintainer": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
'version': '1.0.1',
'author': 'ACSONE SA/NV',
'maintainer': 'ACSONE SA/NV',
'license': 'AGPL-3',
'website': 'http://www.acsone.eu',
'category': 'Political Association',
'depends': [
'mozaik_base',
Expand All @@ -46,15 +47,9 @@
'data': [
'security/ir.model.access.csv',
'data/thesaurus_data.xml',
'thesaurus_view.xml',
],
'qweb': [
],
'demo': [
'views/thesaurus_view.xml',
'wizard/thesaurus_terms_loader_view.xml',
],
'test': [
],
'license': 'AGPL-3',
'sequence': 150,
'installable': True,
'auto_install': False,
Expand Down
15 changes: 15 additions & 0 deletions mozaik_thesaurus/migrations/1.0.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from openerp.tools import SUPERUSER_ID
from openerp.modules.registry import RegistryManager

__name__ = "Delete from Table thesaurus_term"


def migrate(cr, version):
if not version:
return

registry = RegistryManager.get(cr.dbname)
thesaurus_term_obj = registry['thesaurus.term']
thesaurus_term_ids = thesaurus_term_obj.search(cr, SUPERUSER_ID, [])
thesaurus_term_obj.unlink(cr, SUPERUSER_ID, thesaurus_term_ids)
3 changes: 3 additions & 0 deletions mozaik_thesaurus/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import thesaurus
from . import abstract_term_finder
46 changes: 46 additions & 0 deletions mozaik_thesaurus/models/abstract_term_finder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of mozaik_thesaurus, an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# mozaik_thesaurus 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.
#
# mozaik_thesaurus 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 mozaik_thesaurus.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, api


class AbstractTermFinder(models.AbstractModel):

_name = 'abstract.term.finder'
_description = 'Abstract Term Finder'
_terms = []

@api.model
@api.returns('self')
def search(self, args, offset=0, limit=None, order=None, count=False):
if self._terms:
args = [
[
arg[0], 'in', self.env['thesaurus.term'].browse(
arg[2]).get_children_term()
] if hasattr(arg, '__iter__') and arg[0] in self._terms
else arg for arg in args
]
return super(AbstractTermFinder, self).search(
args, offset=offset, limit=limit, order=order, count=count)

0 comments on commit a7d41a0

Please sign in to comment.