Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions base_model_metaclass_mixin/CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0.2
===

* Transformed into a OpenERP module.

661 changes: 661 additions & 0 deletions base_model_metaclass_mixin/LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions base_model_metaclass_mixin/NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from 0.2 to 0.4

* Prepare module for odoo8.
26 changes: 26 additions & 0 deletions base_model_metaclass_mixin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### README ###
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use OCA's readme template here



### Oemetaslfor Odoo/OpenERP ###


This module handles methods and MetaClass to modify OpenERP base methods.
For Exemple, we override copy method to restrict the copy in Odoo/OpenERP.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exAmple

But you can implement the method you need.



How to
======
::

# In an Openerp Module:
from base_model_metaclass_mixin import BaseModelMetaclassMixin


class oetest(osv.Model):
__metaclass__ = BaseModelMetaclassMixin

# Functions defined in BaseModelMetaclassMixin will be automatically added if they are not
# implemented in the osv.Model class

33 changes: 33 additions & 0 deletions base_model_metaclass_mixin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from openerp.osv import orm
from openerp.osv import osv
from openerp.tools.translate import _

__all__ = ['BaseModelMetaclassMixin']


def get_overrides():
overrides = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be global for all databases running on the server. Shouldn't this be per database (as in: Set up the data structure in _register_hook and keep it per registry)?


def add_override(func):
overrides[func.func_name] = func

@add_override
def copy(cls, cr, uid, rec_id, default=None, context=None):
# Raise by default. This method should be implemented to work.

raise osv.except_osv(
_(u"Warning"),
_(u"Copy is not supported for this item.")
)

for func_name, func in overrides.iteritems():
yield func_name, func


class BaseModelMetaclassMixin(orm.MetaModel):
def __init__(cls, name, bases, nmspc):
super(BaseModelMetaclassMixin, cls).__init__(name, bases, nmspc)

for func_name, func in get_overrides():
if func_name not in nmspc:
setattr(cls, func_name, func)
40 changes: 40 additions & 0 deletions base_model_metaclass_mixin/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# BaseModelMetaclassMixin, for OpenERP
# Copyright (C) 2013 XCG Consulting (http://odoo.consulting)
#
# 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/>.
#
# Author: Anael LORIMIER <anael.lorimier@xcg-consulting.fr>
# Vincent Lhote-Hatakeyama <vincent.lhote@xcg-consulting.fr>
#
##############################################################################

{
'name': "BaseModelMetaclassMixin",
'version': '0.5',
'author': "XCG Consulting",
'category': "Custom Module",
'description': """This module handles methods to modify OpenERP base
methods.
""",
'website': "http://www.openerp-experts.com/",
'depends': [
'base',
],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
30 changes: 30 additions & 0 deletions base_model_metaclass_mixin/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_model_metaclass_mixin
# Vincent Lhote-Hatakeyama <vincent.lhote@xcg-consulting.fr>, 2014.
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-28 09:13+0000\n"
"PO-Revision-Date: 2014-04-28 11:30+0200\n"
"Last-Translator: Vincent Lhote-Hatakeyama <vincent.lhote@xcg-consulting.fr>\n"
"Language-Team: XCG Consulting\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Virtaal 0.7.1\n"

#. module: base_model_metaclass_mixin
#: code:addons/base_model_metaclass_mixin/__init__.py:18
#, python-format
msgid "Warning"
msgstr "Avertissement"

#. module: base_model_metaclass_mixin
#: code:addons/base_model_metaclass_mixin/__init__.py:19
#, python-format
msgid "Copy is not supported for this item."
msgstr "La duplication n’est pas possible pour cet objet."