From 7531b5f35ff2cb5e078571184e2ccd1b17ba1c2e Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Wed, 28 Aug 2013 10:36:15 -0400 Subject: [PATCH 1/3] [ADD] document_page_multi_company --- document_page_multi_company/__init__.py | 24 ++++++++ document_page_multi_company/__openerp__.py | 43 +++++++++++++++ .../document_page_multi_company.py | 43 +++++++++++++++ .../document_page_multi_company_view.xml | 55 +++++++++++++++++++ .../i18n/document_page_multi_company.pot | 33 +++++++++++ .../security/document_page_security.xml | 20 +++++++ 6 files changed, 218 insertions(+) create mode 100644 document_page_multi_company/__init__.py create mode 100644 document_page_multi_company/__openerp__.py create mode 100644 document_page_multi_company/document_page_multi_company.py create mode 100644 document_page_multi_company/document_page_multi_company_view.xml create mode 100644 document_page_multi_company/i18n/document_page_multi_company.pot create mode 100644 document_page_multi_company/security/document_page_security.xml diff --git a/document_page_multi_company/__init__.py b/document_page_multi_company/__init__.py new file mode 100644 index 00000000..013e6d95 --- /dev/null +++ b/document_page_multi_company/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (). +# +# 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 . +# +############################################################################## + +import document_page_multi_company + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/document_page_multi_company/__openerp__.py b/document_page_multi_company/__openerp__.py new file mode 100644 index 00000000..03761b7e --- /dev/null +++ b/document_page_multi_company/__openerp__.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (). +# +# 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': 'Document Page Multi-Company', + 'version': '1.0', + "author" : "Savoir-faire Linux", + "website" : "http://www.savoirfairelinux.com", + "license" : "AGPL-3", + 'category': 'Knowledge Management', + 'description': """ +This module adds a company field to document page and the multi-company rule. + """, + 'depends': [ + 'document_page', + ], + 'data': [ + 'security/document_page_security.xml', + 'document_page_multi_company_view.xml', + ], + 'installable': True, + 'auto_install': False, + 'images': [], +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/document_page_multi_company/document_page_multi_company.py b/document_page_multi_company/document_page_multi_company.py new file mode 100644 index 00000000..5f46d86c --- /dev/null +++ b/document_page_multi_company/document_page_multi_company.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Savoir-faire Linux (). +# +# 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 document_page_history(orm.Model): + _inherit = 'document.page.history' + _columns = { + 'company_id': fields.many2one('res.company', 'Company') + } + + _defaults = { + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + } + +class document_page(orm.Model): + _inherit = 'document.page' + _columns = { + 'company_id': fields.many2one('res.company', 'Company') + } + + _defaults = { + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + } + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/document_page_multi_company/document_page_multi_company_view.xml b/document_page_multi_company/document_page_multi_company_view.xml new file mode 100644 index 00000000..62b24bf7 --- /dev/null +++ b/document_page_multi_company/document_page_multi_company_view.xml @@ -0,0 +1,55 @@ + + + + + + + + document.page.history.tree + document.page.history + + + + + + + + + + document.page.history.form + document.page.history + + + + + + + + + + document.page.form + document.page + + + + + + + + + + document.page.tree + document.page + + + + + + + + + + diff --git a/document_page_multi_company/i18n/document_page_multi_company.pot b/document_page_multi_company/i18n/document_page_multi_company.pot new file mode 100644 index 00000000..e9582225 --- /dev/null +++ b/document_page_multi_company/i18n/document_page_multi_company.pot @@ -0,0 +1,33 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * document_page_multi_company +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-08-28 14:33+0000\n" +"PO-Revision-Date: 2013-08-28 14:33+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: document_page_multi_company +#: field:document.page,company_id:0 +#: field:document.page.history,company_id:0 +msgid "Company" +msgstr "" + +#. module: document_page_multi_company +#: model:ir.model,name:document_page_multi_company.model_document_page +msgid "Document Page" +msgstr "" + +#. module: document_page_multi_company +#: model:ir.model,name:document_page_multi_company.model_document_page_history +msgid "Document Page History" +msgstr "" + diff --git a/document_page_multi_company/security/document_page_security.xml b/document_page_multi_company/security/document_page_security.xml new file mode 100644 index 00000000..55c1c8ec --- /dev/null +++ b/document_page_multi_company/security/document_page_security.xml @@ -0,0 +1,20 @@ + + + + + + document_page multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + document_page_history multi-company + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + From 0727881da0c000fc25bbf56c2626ec05f0b29991 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Thu, 29 Aug 2013 08:15:41 -0400 Subject: [PATCH 2/3] [FIX] PEP8 compliance --- document_page_multi_company/__init__.py | 4 ++-- document_page_multi_company/__openerp__.py | 10 +++++----- .../document_page_multi_company.py | 8 +++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/document_page_multi_company/__init__.py b/document_page_multi_company/__init__.py index 013e6d95..19c4eb32 100644 --- a/document_page_multi_company/__init__.py +++ b/document_page_multi_company/__init__.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2013 Savoir-faire Linux (). # @@ -15,7 +15,7 @@ # 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 . +# along with this program. If not, see . # ############################################################################## diff --git a/document_page_multi_company/__openerp__.py b/document_page_multi_company/__openerp__.py index 03761b7e..3dd0017b 100644 --- a/document_page_multi_company/__openerp__.py +++ b/document_page_multi_company/__openerp__.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2013 Savoir-faire Linux (). # @@ -15,16 +15,16 @@ # 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 . +# along with this program. If not, see . # ############################################################################## { 'name': 'Document Page Multi-Company', 'version': '1.0', - "author" : "Savoir-faire Linux", - "website" : "http://www.savoirfairelinux.com", - "license" : "AGPL-3", + "author": "Savoir-faire Linux", + "website": "http://www.savoirfairelinux.com", + "license": "AGPL-3", 'category': 'Knowledge Management', 'description': """ This module adds a company field to document page and the multi-company rule. diff --git a/document_page_multi_company/document_page_multi_company.py b/document_page_multi_company/document_page_multi_company.py index 5f46d86c..de93b0b1 100644 --- a/document_page_multi_company/document_page_multi_company.py +++ b/document_page_multi_company/document_page_multi_company.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2013 Savoir-faire Linux (). # @@ -15,11 +15,12 @@ # 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 . +# along with this program. If not, see . # ############################################################################## from openerp.osv import fields, orm + class document_page_history(orm.Model): _inherit = 'document.page.history' _columns = { @@ -29,7 +30,8 @@ class document_page_history(orm.Model): _defaults = { 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } - + + class document_page(orm.Model): _inherit = 'document.page' _columns = { From fce5f2aa47fedbb74bb2d316bdde69b66fe0ef0f Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Thu, 29 Aug 2013 10:48:37 -0400 Subject: [PATCH 3/3] [FIX] PEP8 compliance and use company_default_get --- document_page_multi_company/__init__.py | 2 +- document_page_multi_company/document_page_multi_company.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/document_page_multi_company/__init__.py b/document_page_multi_company/__init__.py index 19c4eb32..5c8245ab 100644 --- a/document_page_multi_company/__init__.py +++ b/document_page_multi_company/__init__.py @@ -19,6 +19,6 @@ # ############################################################################## -import document_page_multi_company +from . import document_page_multi_company # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/document_page_multi_company/document_page_multi_company.py b/document_page_multi_company/document_page_multi_company.py index de93b0b1..aed9d939 100644 --- a/document_page_multi_company/document_page_multi_company.py +++ b/document_page_multi_company/document_page_multi_company.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + from openerp.osv import fields, orm @@ -28,7 +29,8 @@ class document_page_history(orm.Model): } _defaults = { - 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company') + ._company_default_get(cr, uid, 'document_page_history', context=c) } @@ -39,7 +41,8 @@ class document_page(orm.Model): } _defaults = { - 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company') + ._company_default_get(cr, uid, 'document_page', context=c) } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: