Skip to Content
Menu
This question has been flagged
3 Replies
18708 Views

Hello to all, I have the following problem showing a one2many field on a form view at odoo8. I want to show the fields "days", "morning" and "afternoon" at the form, but only the field "created by" it's shown.  What I'm doing wrong? Thanks in advice.

The code of my model:

from openerp.osv import fields, osv

class res_partner_schedule(osv.osv):

_name = "res.partner.schedule"

_columns = {

'company_id': fields.many2one('res.company', 'Company',

ondelete='cascade'),

'days': fields.char('Days'),

'morning': fields.char('Mornings'),

'afternoon': fields.char('Afternoon'),

}

class res_company(osv.osv):

_inherit = "res.company"

_columns = {

'schedule': fields.one2many('res.partner.schedule', 'company_id', 'Business Hours', help='Schedule of this company'),

}


The code of my view:

<openerp>

<data>

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

<field name="name">res.company.schedule.form</field>

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

<field name="type">form</field>

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

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

<group string="Bank Accounts" position="before">

<group string="Schedule">

<field name="schedule"/>

</group>

</group>

</field>

</record>

</data>

</openerp>

Avatar
Discard
Best Answer

Roberto,

The reason why you are getting only created_by is, you don't have any tree view defined for your object res.partner.schedule so odoo is showing only created_by field as default tree view,

if you wan to show other fields too, you can do it there only, by defining  an inline tree view....as:

<group string="Bank Accounts" position="before">

<group string="Schedule">

<field name="schedule">

                                     <tree>    

                                            <field name="days"/>

                                            <field name="morning"/>

                                          <field name="afternoon"/>

                                     </tree>

                                </field>

</group>

</group>

Avatar
Discard
Author

Thank you so much for your answer. I was divin on the odoo code, but I never thought tree view had relation with form view.

Best Answer


Hi,Are you specified tree tag after declare "schedule" field in your view file

<openerp>

<data>

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

<field name="name">res.company.schedule.form</field>

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

<field name="type">form</field>

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

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

<group string="Bank Accounts" position="before">

<group string="Schedule">

<field name="schedule"/>

                                    <tree>

                                        <field name="days"/>

                                        <field name="morning"/>

                                        <field name="afternoon"/>

                                    </tree>

</group>

</group>

</field>

</record>

</data>

</openerp>





Avatar
Discard
Author

Hmmm. This doesn't work. The view refers to res.company model. Days, morning and afternoon fields belongs to res.partner.schedule, so using this code results on fields not found error.

Author

It works with the tree tag and it's content inside field "schedule" as Pawan answered.

I send code your mail check it now

Author

Thanks for your code and your time. I have given you +1, but I selected pawan's answer as right because he was the first on post, and his answer solved my problem.

Related Posts Replies Views Activity
0
Sep 17
2700
2
Mar 19
24939
0
Mar 15
3088
2
Jun 23
4306
1
Jan 23
1074