From ae875f10378ec35fc2bb500b19c730614ecb963a Mon Sep 17 00:00:00 2001 From: Romain Deheele Date: Mon, 13 Jan 2014 17:34:23 +0100 Subject: [PATCH] [ADD] add continent management addon --- base_continent/__init__.py | 24 ++++++++ base_continent/__openerp__.py | 40 ++++++++++++++ base_continent/base_continent.py | 34 ++++++++++++ base_continent/base_continent_view.xml | 76 ++++++++++++++++++++++++++ base_continent/country.py | 30 ++++++++++ base_continent/partner.py | 34 ++++++++++++ 6 files changed, 238 insertions(+) create mode 100644 base_continent/__init__.py create mode 100644 base_continent/__openerp__.py create mode 100644 base_continent/base_continent.py create mode 100644 base_continent/base_continent_view.xml create mode 100644 base_continent/country.py create mode 100644 base_continent/partner.py diff --git a/base_continent/__init__.py b/base_continent/__init__.py new file mode 100644 index 000000000..89a35d724 --- /dev/null +++ b/base_continent/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2014 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import base_continent +from . import country +from . import partner diff --git a/base_continent/__openerp__.py b/base_continent/__openerp__.py new file mode 100644 index 000000000..d663a0d5e --- /dev/null +++ b/base_continent/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2014 Camptocamp SA +# +# 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": "Continent management", + "version": "1.0", + "depends": ["base"], + "author": "Camptocamp", + "license": "AGPL-3", + "description": """ +This module introduces continent management. +============================================ +Links continents to countries, +adds continent field on partner form +""", + "category": "Generic Modules/Base", + "init_xml": [], + "demo_xml": [], + "update_xml": ["base_continent_view.xml"], + "active": False, + "installable": True, +} diff --git a/base_continent/base_continent.py b/base_continent/base_continent.py new file mode 100644 index 000000000..c48051841 --- /dev/null +++ b/base_continent/base_continent.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2014 Camptocamp SA +# +# 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.orm import Model +from openerp.osv import fields + + +class Continent(Model): + _name = 'res.continent' + _description = 'Continent' + _columns = { + 'name': fields.char('Continent Name', size=64, + help='The full name of the continent.', + required=True, translate=True), + } + _order = 'name' diff --git a/base_continent/base_continent_view.xml b/base_continent/base_continent_view.xml new file mode 100644 index 000000000..e3f3ccecc --- /dev/null +++ b/base_continent/base_continent_view.xml @@ -0,0 +1,76 @@ + + + + + + res.country.tree.add_continent + res.country + tree + + + + + + + + + + + res.country.form.add_continent + form + res.country + + + + + + + + + + res.continent.tree + res.continent + + + + + + + + + res.continent.form + res.continent + +
+ + + +
+
+
+ + + Continents + ir.actions.act_window + res.continent + form + Display and manage the list of all continents that can be assigned to your partner records. + + + + + + + res.partner.form.add_continent + form + res.partner + + + + + + + + +
+
diff --git a/base_continent/country.py b/base_continent/country.py new file mode 100644 index 000000000..b4395763b --- /dev/null +++ b/base_continent/country.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2014 Camptocamp SA +# +# 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.orm import Model +from openerp.osv import fields + + +class Country(Model): + _inherit = 'res.country' + _columns = { + 'continent_id': fields.many2one('res.continent', 'Continent'), + } diff --git a/base_continent/partner.py b/base_continent/partner.py new file mode 100644 index 000000000..a5656652c --- /dev/null +++ b/base_continent/partner.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2014 Camptocamp SA +# +# 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.orm import Model +from openerp.osv import fields + + +class Partner(Model): + _inherit = 'res.partner' + _columns = { + 'continent_id': fields.related('country_id', 'continent_id', + type='many2one', + relation='res.continent', + string='Continent', + readonly=True, store=True), + }