Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to create a new openerp field through function?

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
2 Respuestas
5558 Vistas
Avatar
arsalan

I wanted to know if I want to create a new field then how this can be done. How to set the xml and other details .I think I will have to set them and return the field. But is there any specific function to create new field ? . I have no idea .

Please help Thanks

0
Avatar
Descartar
Jagdish Panchal

You want to add dynamic field ?

arsalan
Autor

first I want to add a new field then I will think a way to add dynamic ones . I f you know any of these plz help

arsalan
Autor

my field is not being displayed

Avatar
Jagdish Panchal
Mejor respuesta

Hi

This will help you https://accounts.openerp.com/forum/Help-1/question/47546

Refer below code

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
    if context is None:
        context = {}
    wiz_id = self.pool.get('ir.actions.act_window').search(cr, uid, [("name","=","analytic.plan.create.model.action")], context=context)
    res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
    journal_obj = self.pool.get('account.journal')
    analytic_plan_obj = self.pool.get('account.analytic.plan')
    if (res['type']=='form'):
        plan_id = False
        if context.get('journal_id', False):
            plan_id = journal_obj.browse(cr, uid, int(context['journal_id']), context=context).plan_id
        elif context.get('plan_id', False):
            plan_id = analytic_plan_obj.browse(cr, uid, int(context['plan_id']), context=context)

        if plan_id:
            i=1
            res['arch'] = """<form string="%s">
<field name="name"/>
<field name="code"/>
<field name="journal_id"/>
<button name="%d" string="Save This Distribution as a Model" type="action" colspan="2"/>
"""% (tools.to_xml(plan_id.name), wiz_id[0])
            for line in plan_id.plan_ids:
                res['arch']+="""
                <field name="account%d_ids" string="%s" nolabel="1" colspan="4">
                <tree string="%s" editable="bottom">
                    <field name="rate"/>
                    <field name="analytic_account_id" domain="[('parent_id','child_of',[%d])]" groups="analytic.group_analytic_accounting"/>
                </tree>
            </field>
            <newline/>"""%(i,tools.to_xml(line.name),tools.to_xml(line.name),line.root_analytic_id and line.root_analytic_id.id or 0)
                i+=1
            res['arch'] += "</form>"
            doc = etree.fromstring(res['arch'].encode('utf8'))
            xarch, xfields = self._view_look_dom_arch(cr, uid, doc, view_id, context=context)
            res['arch'] = xarch
            res['fields'] = xfields
        return res
    else:
        return res
0
Avatar
Descartar
arsalan
Autor

I tried that .But I was unable to get that solution . I think fields_view_get will up grade the already created fields . I want to create fields not upgrade.

Jagdish Panchal

using fields_view_get get you can add dynamic filed. can u paste your code here ?

arsalan
Autor

have u created dynamic fields before?

Jagdish Panchal

yes ? i have

arsalan
Autor

def fields_view_get(self, cr, uid, view_id, view_type='form', context=None,toolbar=False,submenu=False): result = super(deg_form, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) moves_fields=result['fields'] moves_fields.update({ "name" : {'string': 'MyNewName','type': 'char'}}) moves_fields.update({ "data_type" : {'string': 'MyTYPE','type': 'char'}})
moves_fields.update({ "father_name" : {'string': 'MyNewName','type': 'char'}}) # school_obj = self.pool.get('deg.form') result['fields'] = moves_fields # if vi

arsalan
Autor

above here is my function

arsalan
Autor

<button name="fields_view_get" string="CREATE FIELD" type="object" /> And this is button which will call fields_view_get to create fields

arsalan
Autor

can u make me realize whats wrong here

Jagdish Panchal

@arsalan: fields view get call when view load, you want create in button click. So in your case i can't help you.

arsalan
Autor

is there some way I could do this , by any function . If I can return field

arsalan
Autor

hello jack?

Jagdish Panchal

Sorry i have no idea..

arsalan
Autor

ok tell me how can I create fields with fields_view_get function

Jagdish Panchal

I have update ans check try it.

arsalan
Autor

can we give name, data_type etc of our choice or not?

Jagdish Panchal

yes you can type:'Any tyep' , string:'name of field'

arsalan
Autor

but here u have not used my class n objects , I am having problems understanding it. How could I import it in my module

arsalan
Autor

u have used account.journal , journal_id , account_analytic_plan etc . can u explain a bit

arsalan
Autor

because I will have to make changes according to my class.

Jagdish Panchal

There is lost of example in openerp addons module.

arsalan
Autor

ur code is complaining "xml view error". May be u have missed something. Please check

Jagdish Panchal

This code is given in openerp addons>>account_analytic_plans>>account_analytic_plans.py line no : 170 to 210, pls refer this

arsalan
Autor

just tell me how it works if u know. because I really need to understand this to code it

arsalan
Autor

can u code a simple function n edit the one that I sent u . It will be much easier for me to understand the flow of fields_view_get because ur function has an xml issue

Jagdish Panchal

show your code will give solution.

arsalan
Autor

I sent u my code before .Pls do make changes in it

arsalan
Autor

xml issue, because u have not given the xml issue

Avatar
ayman mohammed adam
Mejor respuesta

def fields_view_get(self, cr, uid, view_id, view_type='form', context=None,toolbar=False,submenu=False): result = super(deg_form, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) moves_fields=result['fields'] moves_fields.update({ "name" : {'string': 'MyNewName','type': 'char', 'size': 10}) moves_fields.update({ "data_type" : {'string': 'MyTYPE','type': 'char', 'size': 10}) moves_fields.update({ "father_name" : {'string': 'MyNewName','type': 'char', 'size': 10})

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now