Skip to Content
Menu
This question has been flagged
1 Reply
3582 Views

Hello,

I'm trying to create a module to add extra fields to hr.holidays.

I've created a new menuitem called Travel Request to inherit hr.holidays and apply extra modification.

Here's my code:

class travel_request(models.Model):

_inherit = 'hr.holidays',

_name = 'travel.request'

flight_class = fields.Selection([('business_c','Business class'),('economy_c','Economy class')], 'Flight Class', required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, help="Please choose your flight class", select=True)

trip_type = fields.Selection([('business_t','Business'),('personal_t','personal'),('sales_t', 'Sales')], 'Trip Type', required=True, readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, help="Please choose your desired trip type", select=True)

city_from = fields.Char('From', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]})

city_to = fields.Char('To', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]})

trip_details_ids = fields.One2many('trip.details','travel_req_id', string="Trip Details")

class trip_details(models.Model):

_name = 'trip.details'

from_city = fields.Char('From')

to_city = fields.Char('To')

travel_req_id = fields.Many2one('travel.request', 'Travel Request')

and in my view.xml:

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

<field name="name">Travel Request</field>

<field name="model">travel.request</field>

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

<form string="Travel Request">

 

<sheet>

                     .

                     .

                     .

<notebook colspan="4">

<page string="Trip Details">

<field name="trip_details_ids" />

</page>

<page string="Reason">

<field name="notes" nolabel="1" placeholder="Add a reason..." />

</page>

</notebook>

</sheet>

</form>

</field>

</record>

and here's my output view:

https://drive.google.com/open?id=0B8l_J46zjX-1VXZBRXBWY2c2YTQ

My problem is why the two char fields from_city & to_city are not showing as columns instead of the "Created by" row inside trip details?

Avatar
Discard
Best Answer

Youla,

inspite of

<field name="trip_details_ids" />

try giving :

<field name="trip_details_ids">
     <tree>
         <field name="from_city"/>
         <field name="to_city"/>
         <field name="travel_req_id"/>
     </tree>
</field>


Hope it helps    

Avatar
Discard
Author

Thank you Pawan, it worked.. Looks like the way I used to create modules in openerp 7 isn't working anymore .. And I need to learn the new api

Related Posts Replies Views Activity
2
Aug 22
5659
0
Nov 17
5442
4
Sep 17
23748
0
Feb 16
4458
1
Mar 15
6512