Skip to Content
Menú
This question has been flagged
3 Respostes
20498 Vistes

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
Descartar
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
Descartar
Autor

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
Descartar
Autor

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.

Autor

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

I send code your mail check it now

Autor

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 Respostes Vistes Activitat
0
de set. 17
3585
2
de març 19
28011
0
de març 15
3891
2
de juny 23
7171
1
de gen. 23
2106