Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
5 Antwoorden
9760 Weergaven

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
Annuleer

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

Beste antwoord

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
Annuleer
Auteur

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

Auteur

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

Auteur

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

Beste antwoord

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
Annuleer
Auteur

Unfortunately, that hasn't worked either.

Beste antwoord

Hello,

Please refer below link for field definition.

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

Thanks.

Shamji.

 


Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
jun. 16
2812
0
mei 15
73
3
mei 25
945
1
apr. 25
796
3
sep. 24
13058