Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3120 Tampilan

I want to add timesheet tab of employee in payslip.

My xml code:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="hr_payslip_timesheet_inherit1"
model="ir.ui.view">
<field name="name">HR Payslip Timesheet inherit</field>
<field name="model">hr.payslip</field>
<field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
<field name="arch" type="xml">
<xpath expr="//form[1]/sheet[1]/notebook[1]" position="inside">
<page name="custom_payslip_timesheet" string="Timesheets">
<field name="timesheet_ids" context="{'default_employee_id': employee_id}" domain="[('employee_id', '=', employee_id)]">
<tree editable="bottom" string="Timesheet Activities" default_order="date">
<field name="date"/>
<field name="user_id" invisible="1"/>
<field name="employee_id" required="1" />
<field name="name"/>
<field name="unit_amount" widget="timesheet_uom"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>
</data>
</odoo>

And my python code is like below:

from odoo import models, api, fields


class hr_employee(models.Model):
_inherit = 'hr.payslip'

timesheet_ids = fields.One2many('account.analytic.line', 'employee_id', 'Timesheets')

Any kind of help is appreciated

Avatar
Buang

Hi,

If you are getting any error message using the above code, try to specify it along with the question.

If the above code is not working, change the xpath like this,

<xpath expr="//form/sheet/notebook" position="inside">

Penulis

Sorry being not enough clear. I want to achieve to get timesheet ids of employee on each payslip.

Post Terkait Replies Tampilan Aktivitas
1
Mar 15
6465
1
Jun 20
4283
1
Mar 24
5913
0
Agu 20
2708
1
Jul 19
3777