9 changed files with 353 additions and 0 deletions
-
26partner_rank/__init__.py
-
70partner_rank/__openerp__.py
-
29partner_rank/res_partner.py
-
31partner_rank/res_partner_view.xml
-
53partner_rank/res_rank.py
-
48partner_rank/res_rank_view.xml
-
2partner_rank/security/ir.model.access.csv
-
27partner_rank/tests/__init__.py
-
67partner_rank/tests/test_rank.py
@ -0,0 +1,26 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2014 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.com>). |
|||
# |
|||
# 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 ( |
|||
res_rank, |
|||
res_partner, |
|||
) |
@ -0,0 +1,70 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2014 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.com>). |
|||
# |
|||
# 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/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
{ |
|||
'name': 'Partner Rank', |
|||
'version': '0.1', |
|||
'author': 'Savoir-faire Linux', |
|||
'maintainer': 'Savoir-faire Linux', |
|||
'website': 'http://www.savoirfairelinux.com', |
|||
'license': 'AGPL-3', |
|||
'category': 'Customer Relationship Management', |
|||
'summary': "Manage partner's priority", |
|||
'description': """ |
|||
Manage partner's priority |
|||
========================= |
|||
|
|||
This module allow to setup a rank between partners, manually defined. |
|||
It adds : |
|||
|
|||
1) a new field 'Rank' on the partner form |
|||
2) the ability to group the partners per rank |
|||
3) a new menu 'Sales -> Configuration -> Address Book -> Ranks' |
|||
to define the available Ranks. |
|||
|
|||
Each Rank is defined as : |
|||
|
|||
* a priority (integer) : the lower the most important |
|||
* a name |
|||
* a description |
|||
* the name_get is defined as 'Priority - Name' |
|||
|
|||
Contributors |
|||
------------ |
|||
* El Hadji Dem (elhadji.dem@savoirfairelinux.com) |
|||
""", |
|||
'depends': [ |
|||
'base', |
|||
], |
|||
'external_dependencies': { |
|||
'python': [], |
|||
}, |
|||
'data': [ |
|||
'res_partner_view.xml', |
|||
'res_rank_view.xml', |
|||
'security/ir.model.access.csv', |
|||
], |
|||
'demo': [], |
|||
'test': [], |
|||
'installable': True, |
|||
'auto_install': False, |
|||
} |
@ -0,0 +1,29 @@ |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2014 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.com>). |
|||
# |
|||
# 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 openerp.osv import fields, orm |
|||
|
|||
|
|||
class res_partner(orm.Model): |
|||
_inherit = 'res.partner' |
|||
_columns = { |
|||
'rank_id': fields.many2one('res.rank', 'Partner rank'), |
|||
} |
@ -0,0 +1,31 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<!--Add rank field--> |
|||
<record id="view_partner_rank_form" model="ir.ui.view"> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_form"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="website" position="after"> |
|||
<field name="rank_id"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
<!--Add group for rank field --> |
|||
<record id="view_res_partner__rank_filter" model="ir.ui.view"> |
|||
<field name="name">res.partner..rank.select</field> |
|||
<field name="inherit_id" ref="base.view_res_partner_filter" /> |
|||
<field name="model">res.partner</field> |
|||
<field name="arch" type="xml"> |
|||
<data> |
|||
<filter string="Country" position="after"> |
|||
<filter string="Rank" context="{'group_by': 'rank_id'}"/> |
|||
</filter> |
|||
</data> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,53 @@ |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2014 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.com>). |
|||
# |
|||
# 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 openerp.osv import fields, orm |
|||
|
|||
|
|||
class res_rank(orm.Model): |
|||
_description = 'Rank' |
|||
_name = 'res.rank' |
|||
|
|||
_columns = { |
|||
'name': fields.char( |
|||
'Name', help='Rank name.'), |
|||
'description': fields.text( |
|||
'Description', help='Rank description.'), |
|||
'priority': fields.integer( |
|||
'Priority', help='Rank priority (the lower the most important).'), |
|||
'partner_ids': fields.one2many( |
|||
'res.partner', 'rank_id', 'Partner'), |
|||
} |
|||
|
|||
_sql_constraints = [ |
|||
('priority_uniq', 'UNIQUE(priority)', 'The priority must be unique!'), |
|||
] |
|||
|
|||
def name_get(self, cr, uid, ids, context=None): |
|||
if context is None: |
|||
context = {} |
|||
if type(ids) in (int, long): |
|||
ids = [ids] |
|||
res = [] |
|||
for record in self.browse(cr, uid, ids, context): |
|||
res.append((record.id, str(record.priority) + |
|||
' - ' + record.name)) |
|||
return res |
@ -0,0 +1,48 @@ |
|||
<?xml version="1.0" ?> |
|||
<openerp> |
|||
<data> |
|||
<!-- Tree Views rank--> |
|||
<record model="ir.ui.view" id="rank_tree_view"> |
|||
<field name="name">Rank Tree View</field> |
|||
<field name="model">res.rank</field> |
|||
<field name="type">tree</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="RankTree" version="7.0"> |
|||
<field name="name"/> |
|||
<field name="priority"/> |
|||
<field name="description"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Form Views rank--> |
|||
<record model="ir.ui.view" id="rank_form_view"> |
|||
<field name="name">Rank Form View</field> |
|||
<field name="model">res.rank</field> |
|||
<field name="type">form</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="RankForm" version="7.0" > |
|||
<group col="4"> |
|||
<field name="name"/> |
|||
<field name="priority"/> |
|||
<field name="description"/> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<!-- Actions --> |
|||
<record id="action_res_rank_form" model="ir.actions.act_window"> |
|||
<field name="name">Partner's rank</field> |
|||
<field name="res_model">res.rank</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
<menuitem action="action_res_rank_form" |
|||
id="menu_action_res_rank" |
|||
parent="base.menu_config_address_book" |
|||
groups="base.group_no_one" |
|||
sequence="16"/> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,2 @@ |
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
|||
"access_res_rank","res_rank_user","model_res_rank","base.group_user",1,1,1,1 |
@ -0,0 +1,27 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.com>). |
|||
# |
|||
# 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 test_rank |
|||
|
|||
checks = [ |
|||
test_rank, |
|||
] |
@ -0,0 +1,67 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2014 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.com>). |
|||
# |
|||
# 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 openerp.tests.common import TransactionCase |
|||
from openerp.osv.orm import browse_record |
|||
|
|||
|
|||
class Base_Test_rank(TransactionCase): |
|||
""" |
|||
Simple test creating a rank |
|||
This is a base class for rank test cases. |
|||
Inherit from this and setup values. |
|||
""" |
|||
|
|||
def setUp(self, vals={}): |
|||
""" |
|||
Setting up rank. |
|||
""" |
|||
# Default test values |
|||
self.vals = {'name': 'This is a test rank', |
|||
'priority': 1, |
|||
'description': 'Description for rank', |
|||
} |
|||
super(Base_Test_rank, self).setUp() |
|||
# Overwrite vals if needed |
|||
self.vals = dict(self.vals.items() + vals.items()) |
|||
# Create the rank object; we will be testing this, so store in self |
|||
res_rank = self.registry('res.rank') |
|||
self.rank_id = res_rank.create( |
|||
self.cr, self.uid, self.vals, context=None) |
|||
|
|||
def test_rank(self): |
|||
""" |
|||
Checking the rank creation. |
|||
""" |
|||
res_rank = self.registry('res.rank') |
|||
rank_obj = res_rank.browse( |
|||
self.cr, self.uid, self.rank_id, context=None) |
|||
for field in self.vals: |
|||
val = rank_obj[field] |
|||
if type(val) == browse_record: |
|||
self.assertEquals(self.vals[field], val.id, |
|||
"IDs for %s don't match: (%i != %i)" % |
|||
(field, self.vals[field], val.id)) |
|||
else: |
|||
self.assertEquals(str(self.vals[field]), str(val), |
|||
"Values for %s don't match: (%s != %s)" % |
|||
(field, str(self.vals[field]), str(val))) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue