Reputation: 65
I have added two fields in timesheet detail, i want to add the values of these two fields in account_analytic_line table, how can i do it?
Here is .py file
from osv import osv, fields
class hr_analytic_timesheet(osv.osv):
_inherit = "hr.analytic.timesheet"
_columns = {
'start_at1':fields.char('Start at', size=170),
'end_at1':fields.char('End at', size=170),
}
hr_analytic_timesheet()
And here is view.xml file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="hr_timesheet_inherit">
<field name="name">hr.timesheet.sheet.form</field>
<field name="model">hr_timesheet_sheet.sheet</field>
<field name="type">form</field>
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='unit_amount']" position="after">
<field name="start_at1" />
<field name="end_at1" />
</xpath>
</field>
</record>
</data>
</openerp>
Upvotes: 1
Views: 662
Reputation: 14778
When you look into the technical memento (https://www.openerp.com/files/memento/) on page 2, you will see the 2 types of inheritance in OpenERP.
hr.analytic.timesheet model is using the second one (Delegation or Decorating) and so your fields wont go into the account_analytic_line table, but into the hr_analytic_timesheet table.
if you really want to have this fields in account_analytic_line table just inherit from analytic.account.line and extend that class instead. you can now use the new fields in hr.analytic.timesheet too, so your view with id "hr_timesheet_inherit" should fit anyways (nothing to change here).
hope this will help.
Upvotes: 2