Skip to Content
Menu
This question has been flagged
5 Replies
8789 Views

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
Discard

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
Discard
Author

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

Author

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

Author

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
Discard
Author

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
Discard
Related Posts Replies Views Activity
1
Jun 16
2354
0
May 15
73
3
Sep 24
9969
0
Apr 24
396
2
Feb 24
595