Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

[Solved] Inherit fields to existing tables

Suscribirse

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

Se marcó esta pregunta
pythonpython2.7odooodoo10
4 Respuestas
10291 Vistas
Avatar
Fazryan Fareka Riznendi

Hiiii,
How to inherit field to existing tables?

I've tried various things, but it's hard to understand,

i want to inherit my field(on my addons) to model asset.

this my code ;

class Aset(models.Model): #addons field
    _inherit='asset.asset' 
    
    asset_number = fields.Char('Item Code/Reg', size=64)
    no_pol=fields.Char('Police Number')
    many_units=fields.Char('Number Of Units', default='1')
    item_type_id=fields.Many2one('item_type', string='Item Type')
    colour=fields.Char('Colour')
    machine_number=fields.Char('Number Machine')
    chassiss=fields.Char('Chassis Number')
    fill_in_the_slider=fields.Char('Slider')
    bpkb_no=fields.Char('BPKB No')
    year=fields.Char('Year')

xml ;

<record model="ir.ui.view" id="asset_asset_form_view">
    <field name="name">asset_asset_form</field>
    <field name="model">asset.asset</field>
    <field name="inherit_id" ref="asset.assets_form_view" />
    <field name="arch" type="xml">
        <page position='inside'>
            <group position="inside">
                <field name='serial'>
            <group>
                <field name='color'/>
            </group>
                </field>
       </group>
</page>

Thanks before...

0
Avatar
Descartar
Avatar
La Jayuhni Yarsyah
Mejor respuesta

Based on your code  on <page position='inside'> that  means "Put new tags Inside Element <Page> on referenced view (asset.assets_form_view)"

So the result as attached images. because odoo will render xml structure like this
<page string="Info">
    <group>
        <group>
            ******original fields on group top left
        </group>
    </group>
    <group string="Warranty">
        <group>
            *** Original fields on group bottom left
        </group>
        <group>
            *** Original fields on group bottom right
        </group>
    </group>


    <!-- THE APPENDED TAGS by <page position="inside">**TAGS**</page> -->
    <group>
        <field name='serial'>
    </group>
    <group>
        <field name='color'/>
    </group>
    <!-- END -->
</page>


So for you expected result like image that you attached, maybe you can try like this

<xpath expr="//form/sheet/notebook/page/group[1]" position="inside">
    **Appended tags
</xpath>
** Using group[1] or group (depends on referenced structure)

or

<xpath expr="//form/sheet/notebook/page/group[1]/group" position="after">
    **Appended tags
</xpath>

Note:
The expression depends by referenced views,,so you must modify it base on referenced xml view structure (asset.assets_form_view)

You can see the video that referenced by @Cybrosys before
And please learn about \XPATH\ expression\\ \/\ i\nheriting  View ON Odoo.

Regards

1
Avatar
Descartar
Fazryan Fareka Riznendi
Autor

Thanks for response.

I do both examples,

still not as I expected sir.

the example above makes the field in an existing group, it is almost exactly what I want, but rather want to create a new group and be next to the existing group (as in the picture)

La Jayuhni Yarsyah

So for more please post the original view to inherit (asset.assets_form_view)

And your full xml view code , so me or anyone can help more detail,,

Regards..

Fazryan Fareka Riznendi
Autor

can it be like this? and which object should I edit?

https://drive.google.com/file/d/1375H_YpkqVBw7FSQb_-BmXCwku-b7NOx/view?usp=sharing

Fazryan Fareka Riznendi
Autor

<record model="ir.ui.view" id="asset_asset_form_view">

<field name="name">asset_asset_form</field>

<field name="model">asset.asset</field>

<field name="inherit_id" ref="asset.assets_form_view" />

<field name="arch" type="xml">

<xpath expr="//form/sheet/notebook/page/group" position="inside">

<group>

</group>

<group>

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</group>

</xpath>

<field name='asset_number' position='replace'>

<field name='asset_number'/>

</field>

<field name='active' position='after'>

<field name='item_type_id' />

</field>

<field name='serial' position='after'>

<field name='many_units' />

</field>

</field>

</record>

La Jayuhni Yarsyah

Can you share screen shoot origin form (before inheriting) ?? i wanna see the structure ,, before it inherited

And i see you wanna inherit form view from module wich named "asset" ,, i try to find the module at odoo source code on github (https://github.com/odoo/odoo/tree/10.0/addons) , but cant find "asset" module. It's your own custom module ??

If it right,, can you share the original form view xml structure...??

La Jayuhni Yarsyah

And What the result looks like , if your xpath like this:

<xpath expr="//form/sheet/notebook/page/group[1]/group[1]" position="after">

<group>

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</group>

</xpath>

Fazryan Fareka Riznendi
Autor

now code like this,

<xpath expr="//form/sheet/notebook/page/group" position="inside">

<group>

</group>

<group>

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</group>

</xpath>

and result like in image before...

Fazryan Fareka Riznendi
Autor

origin like this image https://drive.google.com/file/d/1mTJx570PVSSy8XnLmSwGaX38xmyzx3lS/view

and this for module,

https://apps.odoo.com/apps/modules/10.0/asset/

I just added a new field to the module, because when I tried to add a field directly to the module it couldn't, so I made simple addons for the inheritance

La Jayuhni Yarsyah

I see on that module repository on -> https://github.com/codup/odoo-eam/blob/10.0/asset/asset_view.xml#L72

There's Empty Group Already defined on origin form view, it post wil be rendered on top right of form

So in this case, can you try to put this code:

<xpath expr="//form/sheet/notebook/page/group[1]/group[2]" position="inside">

<field name='colour'/>

<field name='machine_number'/>

<field name='chassiss'/>

<field name='fill_in_the_slider'/>

<field name='bpkb_no'/>

<field name='year'/>

</xpath>

and see the result

Fazryan Fareka Riznendi
Autor

Hi La Jayuhni,

Big Thanks, now it's appropriate

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,

If you are looking to inherit and add new custom fields to the model asset.asset , what you have done seems to be fine, if there is an issue in the same, please post the issue or update the question with the error message.

Additional field to existing view

Thanks


1
Avatar
Descartar
Fazryan Fareka Riznendi
Autor

Hello, Thanks for response

there was no error, but the addons field that I added was not in the 'Info' table and grouped there. but instead adds the fields below.

and essentially I want to add fields with new groups next to existing groups,

regards.

Fazryan Fareka Riznendi
Autor

if you are confused, you can see this picture for what I mean;

https://drive.google.com/file/d/1mTJx570PVSSy8XnLmSwGaX38xmyzx3lS/view?usp=sharing

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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
[SOLVED] How to Hide or Delete Trash Icon in One2many field Resuelto
python python2.7 odoo odoo10
Avatar
Avatar
2
ago 25
12903
Filter value 2 field of Many2one
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
5
sept 20
6952
Filter field domain one2many to many2one Resuelto
python python2.7 odoo odoo10
Avatar
Avatar
1
dic 19
10318
How to calculate the value of results in one2many field
python python2.7 odoo odoo10
Avatar
Avatar
1
ene 19
7122
Generate XLSX(Excel) report in odoo 10 from custom module?
python python2.7 odoo odoo10
Avatar
Avatar
Avatar
2
jul 18
15329
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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