Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
5333 Lượt xem

Hii,
We want to customize Leaves module in Odoo 12. 
Requirement:
a) When an Employee create a Leave Request, there should be option to select Substitute Employee.
b) When submitting leave request, First it should go to Substitute Employee for Approval in the workflow, then to his manager, then HR manager, that is already in Leave workflow. How to add substitute employee in the Workflow?
c) Substitute employee should receive email from the workflow, click the button in email and approve in Odoo?

Please guide how to do customization, what could the suggested steps to get the solution,
1) Creating a new App and inherent from hr_holidays and adding substitute employee field?
2) Which view to update to show substitute employee?
3) How to customize the Leave workflow and send email to substitute employee and adding his approval?

Thanks, 


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thanks @Niyas and @Mihran,

How to add new value in state field which is in hr.leave model? 
Here is code state = fields.Selection(selection_add=[('validate_substitute', 'Substitute Approval')]) but it is adding at the end of statusbar but need after draft value.

Here is my view code

Thanks,

Ảnh đại diện
Huỷ bỏ
Tác giả

<odoo>

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

<field name="name">Leave Form Custom</field>

<field name="model">hr.leave</field>

<field name="inherit_id" ref="hr_holidays.hr_leave_view_form"/>

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

<field name="name" position="before">

<field name="substitute_employee_id" />

</field>

<!-- Statusbar widget with the new status -->

<xpath expr="//field[@name='state']" position="replace">

<field name="state" widget="statusbar" statusbar_visible="confirm,validate_substitute,validate"/>

</xpath>

<!-- Add New Button -->

<xpath expr="/form/header/button[@name='action_confirm']" position="after">

<button name="action_validate_substitute" states="confirm" string="Substitute Approval" class="oe_highlight" type="object"/>

<button string="Approve" name="action_approve" type="object" class="oe_highlight" attrs="{'invisible': ['|', ('can_approve', '=', False), ('state', '!=', 'validate_substitute')]}"/>

</xpath>

</field>

</record>

</odoo>

But it is not appearing in order.. What is want

1) Draft

2) After Confirm

3) Substitute Approval

4) Then rest as standard

Hi,

Instead of using selection_add try using selection and replace all the states

Tác giả

Hii,

How to know that only the substitute employee should approve this leave?

Means the new Substitute Approval button in the header should be visible to Substitute Employee only.

Thanks,

Tác giả

Hii,

One more question along with the above one.

Now the workflow state is validate_substitute (the new state I added) and when I click the Approve button, its giving me following odoo error "Leave request must be confirmed ("To Approve") in order to approve it."

While state validate_substitute comes after confirm.

What could be the reason?

Thanks,

Tác giả

Hii @Niyas Raphy and @Mihran Thalhath

How to handel above two questions.

Thanks,

Câu trả lời hay nhất

Hi Anees,


1. Inherit 'hr.leave' and add new substitute_employee_id field which is many2one field to hr.employee.
2. When a user selects a substitute employee and saves the request, send an email notification to the substitute employee.
3. The state of the leave request should now move to new one, which preferably should be a new one you added. The create function should help you with this state change.
4. Now add a new button in the header which is visible for the substitute employee. This button should change the state to confirm. From there on it should be your default Odoo workflow.

You can get the format for sending emails and adding buttons from Niyas' answer. If you have any doubt feel free to ask.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

For this first of all you have to add a new field for adding/specifying the substitute employee in the leave request form. For inheriting and adding new field to an existing view, please read this blog:  How to Add Custom Fields to Existing Views in Odoo v12

Regarding the approval from the substitute employee you have to alter the current work flow and add a new button for that purpose, to see the working of the workflow, see :  How to Define Header, Statusbar, and Buttons


And for sending the Email from code: Finding and sending e-mail templates

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 20
2682
0
thg 3 15
5292
0
thg 3 15
3994
1
thg 9 25
207
1
thg 8 25
529