Ir al contenido
Menú
Se marcó esta pregunta
5 Respuestas
9729 Vistas

Hello

I have followed instruction from an odoo class video but I can't see to get the field to be added to existing model:

CLASS:

class test(models.Model):

_name = 'res.partner'

_inherit = 'res.partner'

columns = {

testfield = fields.Char('TEST', size=20)

}


VIEW:

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

<field name="model">res.partner</field>

<field name="inherit_id" ref="base.view_partner_form" />

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

<field name="title" position="after">

<field name="testfield" />

</field>

</field>

</record>


No errors but no field where I would like it to be either. In development mode base.view_partner_form is the correct external ID. Please can someone help

Avatar
Descartar

restarted odoo server after these changes, then updated (with "upgrade" button) corresponding module ?

Mejor respuesta

Hi Siobhan,

Try this one,

__.py

class res_partner(models.Model):

    _inherit = 'res.partner'

    testfield = fields.Char(string='TEST', size=20)

__.xml

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

<field name="name">res.partner.inherited.form.view</field>

<field name="model">res.partner</field>

<field name="inherit_id" ref="base.view_partner_form" />

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

<field name="title" position="after">

<field name="testfield" />

</field>

</field>

</record>


Hope this will help u little bit...

Avatar
Descartar
Autor

It is telling me that "testfield" doesn't exist. Copy and pasted the code above and now I get this error_: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 530, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1399, in _dispatch_nodb func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match() File "/usr/lib/python2.7/dist-packages/werkzeug/routing.py", line 1423, in match raise NotFound() NotFound: 404: Not Found

Autor

Finally it worked.... I don't know what exactly when wrong or how it worked but in the end I uninstalled the module. Deleted everything I had done so far and then readded the code. It seemed to like it better when I uninstalled the module before I changed the code.. Only problem with this is that all my data is lost. I am going to try this again with existing module to see if it works without uninstalling the module. Thank you all for your help

Autor

Tried with another module and it is working.... really not sure where it went wrong to begin with.

Mejor respuesta

Try this,

class res_partner(models.Model): 

_inherit = 'res.partner'

 testfield = fields.Char(string='TEST', size=20)


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

        <field name="model">res.partner</field>

        <field name="inherit_id" ref="base.view_partner_form" />

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

            <field name="title" position="after">

                <field name="testfield" />

            </field>

        </field>

</record>

Avatar
Descartar
Autor

Unfortunately, that hasn't worked either.

Mejor respuesta

Hello,

Please refer below link for field definition.

https://www.odoo.com/documentation/8.0/howtos/backend.html#model-fields

Thanks.

Shamji.

 


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
jun 16
2780
0
may 15
73
3
may 25
874
1
abr 25
742
3
sept 24
12933