Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
20504 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
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.

Nejlepší odpověď


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
Zrušit
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 Odpovědi Zobrazení Aktivita
0
zář 17
3587
2
bře 19
28024
0
bře 15
3904
2
čvn 23
7177
1
led 23
2112