Skip to content
Snippets Groups Projects
analytic_dimension.py 2.19 KiB
Newer Older
Alexandre Allouche's avatar
Alexandre Allouche committed
# -*- coding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2013 XCG Consulting (www.xcg-consulting.fr)
#
#    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 import models, fields
from openerp.addons.oemetasl import OEMetaSL
from openerp.tools import config



    def __new__(cls, name, bases, nmspc):

        size = int(config.get_misc('analytic', 'analytic_size', 5))
        for n in xrange(1, size + 1):
Matthieu Gautier's avatar
Matthieu Gautier committed
            nmspc['ns{}_id'.format(n)] = fields.One2many(
        return super(_dimension_meta, cls).__new__(cls, name, bases, nmspc)
Alexandre Allouche's avatar
Alexandre Allouche committed


Matthieu Gautier's avatar
Matthieu Gautier committed
class analytic_dimension(models.Model):
Houzefa Abbasbhay's avatar
Houzefa Abbasbhay committed
    _name = 'analytic.dimension'
Alexandre Allouche's avatar
Alexandre Allouche committed

Matthieu Gautier's avatar
Matthieu Gautier committed
    name = fields.Char(
        string=u"Name",
        size=128,
        translate=config.get_misc('analytic', 'translate', False),
        required=True,
    )
Matthieu Gautier's avatar
Matthieu Gautier committed
    nc_ids = fields.One2many(
        comodel_name='analytic.code',
        inverse_name='nd_id',
        string=u"Codes")
Matthieu Gautier's avatar
Matthieu Gautier committed
    ns_id = fields.One2many(
        comodel_name='analytic.structure',
        inverse_name='nd_id',
        string=u"Structures")
Alexandre Allouche's avatar
Alexandre Allouche committed

    _sql_constraints = [
        ('unique_name', 'unique(name)', u"Name must be unique"),
Alexandre Allouche's avatar
Alexandre Allouche committed
    ]