Merge branch 'leave_manage' into 'development'

Leave manage

See merge request prakash.jain/cor-odoo!185
This commit is contained in:
pawan.sharma 2021-07-09 12:40:32 +00:00
commit feffe2b3cc
3 changed files with 78 additions and 76 deletions

View File

@ -71,49 +71,49 @@ class CompanyResourceCalendar(models.Model):
Calendar = self.env['calendar.event']
for comp_global_leave in self.company_global_leave_ids:
public_holiday.append({
'name': "Holiday"+"/"+comp_global_leave.name,
'name': "Holiday" + "/" + comp_global_leave.name,
'start': comp_global_leave.date_from,
'stop': comp_global_leave.date_to,
'categ_ids': [(6, 0, [self.env.ref('company_public_holidays_kanak.categ_meet6').id])]
})
})
for holiday in public_holiday:
existing_calender = Calendar.search([('start', '=', holiday['start'])])
if not existing_calender:
Calendar.create(holiday)
# def action_holiday_update_timeoff_calendar(self):
# public_holiday = []
# holiday_id = self.env['hr.leave.type'].search([], limit=1)
# company = self.env['res.company'].search([], limit=1)
# employee = self.env['hr.employee'].search([('id', '=', 14)], limit=1)
# #leave_calendar = self.env['hr.leave']
# leave_calendar = self.env['hr.leave'].with_context(
# tracking_disable=True,
# mail_activity_automation_skip=True,
# leave_fast_create=True,
# leave_skip_state_check=True,
# )
# for comp_global_leave in self.company_global_leave_ids:
# public_holiday.append({
# 'name': "Holiday"+"/"+comp_global_leave.name,
# 'date_from': comp_global_leave.date_from,
# 'date_to': comp_global_leave.date_to,
# 'holiday_status_id': holiday_id.id,
# 'employee_id': employee.id,
# 'state': 'validate'
# })
# for holiday in public_holiday:
# existing_calender = leave_calendar.search([('date_from', '=', holiday['date_from'])])
# if not existing_calender:
# leave_calendar.create(holiday)
def action_holiday_update_timeoff_calendar(self):
public_holiday = []
holiday_id = self.env['hr.leave.type'].search([], limit=1)
employees = self.env['hr.employee'].search([])
# leave_calendar = self.env['hr.leave']
leave_calendar = self.env['hr.leave']
for comp_global_leave in self.company_global_leave_ids:
for employee in employees:
existing_calender = leave_calendar.search([('date_from', '=', comp_global_leave.date_from),('employee_id', '=', employee.id)])
if not existing_calender:
leave_calendar.with_context(
tracking_disable=True,
mail_activity_automation_skip=True,
leave_fast_create=True,
leave_skip_state_check=True,
).create({
'name': "Holiday" + "/" + comp_global_leave.name,
'date_from': comp_global_leave.date_from,
'date_to': comp_global_leave.date_to,
'holiday_status_id': holiday_id.id,
'employee_id': employee.id,
'state': 'validate'
})
self.action_holiday_update_calendar()
class CompanyResourceCalendarLeaves(models.Model):
_name = 'company.resource.calendar.leaves'
_description = 'Company Resouce Calendar Leaves'
name = fields.Char('Reason')
name = fields.Char('Reason', required=True)
company_calendar_id = fields.Many2one('company.resource.calendar', 'Working Hours')
date_from = fields.Datetime('Start Date', required=True)
date_to = fields.Datetime('End Date', required=True)
@ -135,13 +135,15 @@ class CompanyResourceCalendarLeaves(models.Model):
return res
def write(self, values):
resource_calendar = self.env['resource.calendar.leaves'].search([('company_res_calendar_leaves_id', '=', self.id)])
resource_calendar = self.env['resource.calendar.leaves'].search(
[('company_res_calendar_leaves_id', '=', self.id)])
resource_calendar.write(values)
res = super(CompanyResourceCalendarLeaves, self).write(values)
return res
def unlink(self):
resource_calendar = self.env['resource.calendar.leaves'].search([('company_res_calendar_leaves_id', '=', self.id)])
resource_calendar = self.env['resource.calendar.leaves'].search(
[('company_res_calendar_leaves_id', '=', self.id)])
resource_calendar.unlink()
res = super(CompanyResourceCalendarLeaves, self).unlink()
return res
@ -150,7 +152,8 @@ class CompanyResourceCalendarLeaves(models.Model):
class ResourceCalendarLeaves(models.Model):
_inherit = "resource.calendar.leaves"
company_res_calendar_leaves_id = fields.Many2one('company.resource.calendar.leaves', string='Company Resouce Calendar')
company_res_calendar_leaves_id = fields.Many2one('company.resource.calendar.leaves',
string='Company Resouce Calendar')
class MailComposer(models.TransientModel):

View File

@ -28,8 +28,8 @@
<form string="Company Public Holiday">
<header>
<button name="action_public_holiday_send" string="Send by Email" type="object" class="btn-primary"/>
<button name="action_holiday_update_calendar" string="Update Holiday Calendar" type="object" class="btn-primary"/>
<!--<button name="action_holiday_update_timeoff_calendar" string="Update Holiday Calendar" type="object" class="btn-primary"/>-->
<!--<button name="action_holiday_update_calendar" string="Update Holiday Calendar" type="object" class="btn-primary"/>-->
<button name="action_holiday_update_timeoff_calendar" string="Update Holiday Calendar" type="object" class="btn-primary"/>
</header>
<sheet>
<group>

View File

@ -1,49 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="project_project_analytic_view_form" model="ir.ui.view">
<field name="name">Project Analytic</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<!--<div name="button_box" position="inside">
<button class="oe_stat_button" type="object" name="action_view_account_analytic_line" icon="fa-usd"
attrs="{'invisible': [('allow_billable','=',False)]}" string="Cost/Revenue" widget="statinfo">
</button>
</div>-->
<xpath expr="//field[@name='user_id']" position="replace">
<field name="user_id" string="Project Manager" widget="many2one_avatar_user" required="0"
attrs="{'readonly':[('active','=',False)]}" domain="[('share', '=', False)]"/>
</xpath>
<xpath expr="//field[@name='partner_id']" position="replace">
<field name="partner_id" string="Client" required="0"/>
<field name="date_start"/>
<field name="date"/>
</xpath>
<xpath expr="//page[@name='settings']" position="after">
<page string="Consultant Allocation"
attrs="{'invisible':['|',('pricing_type','!=','employee_rate'),('project_type','!=','hours_in_consultant')]}">
<field name="project_cons_hrs">
<tree editable="top">
<field name="project_id" invisible="1"/>
<field name="employee_id" options="{'no_create_edit': True, 'no_quick_create': True}"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="percentage"/>
<field name="budgeted_hours"/>
<field name="actual_percentage"/>
<field name="actual_hours"/>
</tree>
</field>
</page>
</xpath>
<xpath expr="//field[@name='privacy_visibility']" position="before">
<field name="tag_ids" widget="many2many_tags"/>
</xpath>
</field>
</record>
<record id="inherit_project_project_view_form" model="ir.ui.view">
<field name="name">project.project.form.inherit</field>
<field name="model">project.project</field>
@ -169,6 +126,48 @@
</field>
</record>
<record id="project_project_analytic_view_form" model="ir.ui.view">
<field name="name">Project Analytic</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<!--<div name="button_box" position="inside">
<button class="oe_stat_button" type="object" name="action_view_account_analytic_line" icon="fa-usd"
attrs="{'invisible': [('allow_billable','=',False)]}" string="Cost/Revenue" widget="statinfo">
</button>
</div>-->
<xpath expr="//field[@name='user_id']" position="replace">
<field name="user_id" string="Project Manager" widget="many2one_avatar_user" required="0"
attrs="{'readonly':[('active','=',False)]}" domain="[('share', '=', False)]"/>
</xpath>
<xpath expr="//field[@name='partner_id']" position="replace">
<field name="partner_id" string="Client" required="0"/>
<field name="date_start"/>
<field name="date"/>
</xpath>
<xpath expr="//page[@name='settings']" position="after">
<page string="Consultant Allocation"
attrs="{'invisible':['|',('pricing_type','!=','employee_rate'),('project_type','!=','hours_in_consultant')]}">
<field name="project_cons_hrs">
<tree editable="top">
<field name="project_id" invisible="1"/>
<field name="employee_id" options="{'no_create_edit': True, 'no_quick_create': True}"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="percentage"/>
<field name="budgeted_hours"/>
<field name="actual_percentage"/>
<field name="actual_hours"/>
</tree>
</field>
</page>
</xpath>
<xpath expr="//field[@name='privacy_visibility']" position="before">
<field name="tag_ids" widget="many2many_tags"/>
</xpath>
</field>
</record>
<record id="inherit_view_project_tree" model="ir.ui.view">
<field name="name">project.project.tree.inherit</field>