Skip to Content
Menú
This question has been flagged
5 Respostes
9511 Vistes

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 ?

Best Answer

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.

Best Answer

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.

Best Answer

Hello,

Please refer below link for field definition.

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

Thanks.

Shamji.

 


Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de juny 16
2722
0
de maig 15
73
3
de maig 25
615
1
d’abr. 25
440
3
de set. 24
12426