From 027312986c83da9f44da20f76021877b8b56d6e7 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Wed, 10 Jun 2015 14:45:43 +0200 Subject: [PATCH] [MOD] partner_industry/ies: some users want to manage only one industry, others want to manage multiple industries. So let's create 2 modules to fit both cases --- partner_industries/README.rst | 25 +++++++++++++ partner_industries/__init__.py | 7 ++++ partner_industries/__openerp__.py | 39 ++++++++++++++++++++ partner_industries/model/__init__.py | 2 ++ partner_industries/model/industry.py | 36 +++++++++++++++++++ partner_industries/model/partner.py | 32 +++++++++++++++++ partner_industries/view/industry.xml | 54 ++++++++++++++++++++++++++++ partner_industries/view/partner.xml | 34 ++++++++++++++++++ partner_industry/model/partner.py | 6 ++-- partner_industry/view/partner.xml | 8 ++--- 10 files changed, 235 insertions(+), 8 deletions(-) create mode 100644 partner_industries/README.rst create mode 100644 partner_industries/__init__.py create mode 100644 partner_industries/__openerp__.py create mode 100644 partner_industries/model/__init__.py create mode 100644 partner_industries/model/industry.py create mode 100644 partner_industries/model/partner.py create mode 100644 partner_industries/view/industry.xml create mode 100644 partner_industries/view/partner.xml diff --git a/partner_industries/README.rst b/partner_industries/README.rst new file mode 100644 index 000000000..2a5707759 --- /dev/null +++ b/partner_industries/README.rst @@ -0,0 +1,25 @@ +Industry sector on partner +========================== + +This addon adds an industry sector object and a field 'Industry sectors' after the tags on the partner form view. + +Credits +======= + +Contributors +------------ + +* Jacques-Etienne Baudoux (BCIM sprl) + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/partner_industries/__init__.py b/partner_industries/__init__.py new file mode 100644 index 000000000..24ea95a61 --- /dev/null +++ b/partner_industries/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# +# License, author and contributors information in: +# __openerp__.py file at the root folder of this module. +# + +from . import model diff --git a/partner_industries/__openerp__.py b/partner_industries/__openerp__.py new file mode 100644 index 000000000..e4d33980a --- /dev/null +++ b/partner_industries/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Jacques-Etienne Baudoux +# Copyright 2015 BCIM sprl +# +# 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 . +# +############################################################################## + +{ + 'name': 'Partner Industry Sector', + 'version': '1.0', + 'author': "BCIM,Odoo Community Association (OCA)", + 'maintainer': 'BCIM', + 'category': 'Sales Management', + 'complexity': 'easy', + 'depends': ['base'], + 'website': 'http://www.bcim.be', + 'data': [ + 'view/industry.xml', + 'view/partner.xml', + ], + 'installable': True, + 'auto_install': False, + 'license': 'AGPL-3', + 'application': False, +} diff --git a/partner_industries/model/__init__.py b/partner_industries/model/__init__.py new file mode 100644 index 000000000..2dd337f99 --- /dev/null +++ b/partner_industries/model/__init__.py @@ -0,0 +1,2 @@ +from . import industry +from . import partner diff --git a/partner_industries/model/industry.py b/partner_industries/model/industry.py new file mode 100644 index 000000000..73c1fca70 --- /dev/null +++ b/partner_industries/model/industry.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Jacques-Etienne Baudoux +# Copyright 2015 BCIM sprl +# +# 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 . +# +############################################################################## + +from openerp.osv import fields, orm + + +class Industry(orm.Model): + _name = 'res.partner.category.industry' + _inherit = 'res.partner.category' + + _columns = { + 'code': fields.char('Code', size=16), + 'parent_id': fields.many2one(_name, 'Parent Category', select=True, ondelete='cascade'), + 'partner_ids': fields.many2many( + 'res.partner', + 'res_partner_industry_rel', 'industry_id', 'partner_id', + 'Partners'), + } diff --git a/partner_industries/model/partner.py b/partner_industries/model/partner.py new file mode 100644 index 000000000..c5cbd96d2 --- /dev/null +++ b/partner_industries/model/partner.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Jacques-Etienne Baudoux +# Copyright 2015 BCIM sprl +# +# 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 . +# +############################################################################## + +from openerp.osv import fields, orm + + +class res_partner(orm.Model): + _inherit = 'res.partner' + _columns = { + 'industry_ids': fields.many2many( + 'res.partner.category.industry', + 'res_partner_industry_rel', 'partner_id', 'industry_id', + 'Industries'), + } diff --git a/partner_industries/view/industry.xml b/partner_industries/view/industry.xml new file mode 100644 index 000000000..1c43426e9 --- /dev/null +++ b/partner_industries/view/industry.xml @@ -0,0 +1,54 @@ + + + + + + Industry + res.partner.category.industry + +
+ + +
+
+
+ + + Industry + res.partner.category.industry + + + + + + + + + + Industry Sectors + res.partner.category.industry + form + tree,form + + + + + +
+
+ diff --git a/partner_industries/view/partner.xml b/partner_industries/view/partner.xml new file mode 100644 index 000000000..838672f0b --- /dev/null +++ b/partner_industries/view/partner.xml @@ -0,0 +1,34 @@ + + + + + + res.partner.search.industry + res.partner + + + + + + + + + + + res.partner.form.industry + res.partner + + + + + + + + + + diff --git a/partner_industry/model/partner.py b/partner_industry/model/partner.py index c5cbd96d2..98c292fe8 100644 --- a/partner_industry/model/partner.py +++ b/partner_industry/model/partner.py @@ -25,8 +25,8 @@ from openerp.osv import fields, orm class res_partner(orm.Model): _inherit = 'res.partner' _columns = { - 'industry_ids': fields.many2many( + 'industry_id': fields.many2one( 'res.partner.category.industry', - 'res_partner_industry_rel', 'partner_id', 'industry_id', - 'Industries'), + 'Industry Sector', + ondelete='restrict'), } diff --git a/partner_industry/view/partner.xml b/partner_industry/view/partner.xml index 838672f0b..041e7278c 100644 --- a/partner_industry/view/partner.xml +++ b/partner_industry/view/partner.xml @@ -8,13 +8,11 @@ - + - @@ -24,7 +22,7 @@ -