Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
20516 Widoki

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>

Awatar
Odrzuć
Najlepsza odpowiedź

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>

Awatar
Odrzuć
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.

Najlepsza odpowiedź


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>





Awatar
Odrzuć
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.

Powiązane posty Odpowiedzi Widoki Czynność
0
wrz 17
3615
2
mar 19
28068
0
mar 15
3925
2
cze 23
7255
1
sty 23
2135