|
@@ -0,0 +1,108 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+##############################################################################
|
|
|
+#
|
|
|
+# OpenERP, Open Source Management Solution
|
|
|
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
|
|
+#
|
|
|
+# 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.osv import fields, osv
|
|
|
+
|
|
|
+def location_name_search(self, cr, user, name='', args=None, operator='ilike',
|
|
|
+ context=None, limit=100):
|
|
|
+ if not args:
|
|
|
+ args = []
|
|
|
+
|
|
|
+ ids = []
|
|
|
+ if len(name) == 6:
|
|
|
+ ids = self.search(cr, user, [('code', 'ilike', name)] + args,
|
|
|
+ limit=limit, context=context)
|
|
|
+
|
|
|
+ search_domain = [('name', operator, name)]
|
|
|
+ if ids: search_domain.append(('id', 'not in', ids))
|
|
|
+ ids.extend(self.search(cr, user, search_domain + args,
|
|
|
+ limit=limit, context=context))
|
|
|
+
|
|
|
+ locations = self.name_get(cr, user, ids, context)
|
|
|
+ return sorted(locations, key=lambda (id, name): ids.index(id))
|
|
|
+
|
|
|
+class Repetidora(osv.osv):
|
|
|
+ _name = 'res.repetidora'
|
|
|
+ _description = 'Repetidora'
|
|
|
+ _columns = {
|
|
|
+ 'name': fields.char('Descripcion Repetidora',
|
|
|
+ help='El nombre completo de Repetidora.', required=True),
|
|
|
+ 'code': fields.char('Repetidora Codigo', size=6,
|
|
|
+ help='El codigo de repetidora en cuatro caracter.\n'
|
|
|
+ 'Puedes utilizar este campo para una busqueda rapida.'),
|
|
|
+ 'address_format': fields.text('Formato Repetidora', help="""You can use the python-style string patern with all the field of the address \
|
|
|
+(for example, use '%(street)s' to display the field 'street') plus
|
|
|
+ \n%(state_name)s: the name of the state
|
|
|
+ \n%(state_code)s: the code of the state
|
|
|
+ \n%(country_name)s: the name of the country
|
|
|
+ \n%(country_code)s: the code of the country"""),
|
|
|
+ 'repetidora_group_ids': fields.many2many('res.repetidora.group', 'res_repetidora_res_repetidora_group_rel', 'res_repetidora_id', 'res_repetidora_group_id', string='Grupo repetidora'),
|
|
|
+ }
|
|
|
+ _sql_constraints = [
|
|
|
+ ('name_uniq', 'unique (name)',
|
|
|
+ 'La descripcion de la repetidora debe ser unica !'),
|
|
|
+ ('code_uniq', 'unique (code)',
|
|
|
+ 'El codigo de la repetidora de la repetidora debe ser unica !')
|
|
|
+ ]
|
|
|
+ _defaults = {
|
|
|
+ 'address_format': "%(city)s %(state_code)s \n%(country_name)s",
|
|
|
+ }
|
|
|
+ _order='name'
|
|
|
+
|
|
|
+ name_search = location_name_search
|
|
|
+
|
|
|
+ def create(self, cursor, user, vals, context=None):
|
|
|
+ if vals.get('code'):
|
|
|
+ vals['code'] = vals['code'].upper()
|
|
|
+ return super(Repetidora, self).create(cursor, user, vals,
|
|
|
+ context=context)
|
|
|
+
|
|
|
+ def write(self, cursor, user, ids, vals, context=None):
|
|
|
+ if vals.get('code'):
|
|
|
+ vals['code'] = vals['code'].upper()
|
|
|
+ return super(Repetidora, self).write(cursor, user, ids, vals,
|
|
|
+ context=context)
|
|
|
+
|
|
|
+
|
|
|
+class RepetidoraGroup(osv.osv):
|
|
|
+ _description="Grupo Repetidora"
|
|
|
+ _name = 'res.repetidora.group'
|
|
|
+ _columns = {
|
|
|
+ 'name': fields.char('Name', required=True),
|
|
|
+ 'repetidora_ids': fields.many2many('res.repetidora', 'res_repetidora_res_repetidora_group_rel', 'res_repetidora_group_id', 'res_repetidora_id', string='Repetidoras'),
|
|
|
+ }
|
|
|
+
|
|
|
+class RepetidoraSectorial(osv.osv):
|
|
|
+ _description="Sectorial"
|
|
|
+ _name = 'res.repetidora.sectorial'
|
|
|
+ _columns = {
|
|
|
+ 'repetidora_id': fields.many2one('res.repetidora', 'Repetidora',
|
|
|
+ required=True),
|
|
|
+ 'name': fields.char('Nombre Sectorial', required=True,
|
|
|
+ help='Descripcion Sectorial.'),
|
|
|
+ 'code': fields.char('Codigo Sectorial', size=6,
|
|
|
+ help='El codigo sectorial en max. cuatro caracteres.', required=True),
|
|
|
+ }
|
|
|
+ _order = 'code'
|
|
|
+
|
|
|
+ name_search = location_name_search
|
|
|
+
|
|
|
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|