Add traking on warn fields

WORK IN PROGRESS: port hr_holidays_usability
This commit is contained in:
Alexis de Lattre
2017-04-05 19:22:01 +02:00
parent ffda316d34
commit 348e0205a0
24 changed files with 241 additions and 374 deletions

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import account
from . import partner

View File

@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class ResPartner(models.Model):
_inherit = 'res.partner'
invoice_warn = fields.Selection(track_visibility='onchange')

View File

@@ -1,46 +1,27 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2015-2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'HR Holidays Usability',
'version': '0.1',
'version': '10.0.1.0.0',
'category': 'Human Resources',
'license': 'AGPL-3',
'summary': 'Better usability for the management of holidays',
'description': '',
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['hr_holidays', 'hr_public_holidays'],
'data': [
'wizard/hr_holidays_mass_allocation_view.xml',
'wizard/hr_holidays_post_view.xml',
'report/hr_holidays_employee_counter_view.xml',
'hr_holidays_view.xml',
'hr_holidays_mail.xml',
'res_company_view.xml',
'base_config_settings_view.xml',
'hr_employee_view.xml',
'security/holiday_security.xml',
'security/ir.model.access.csv',
'wizard/hr_holidays_mass_allocation_view.xml',
'wizard/hr_holidays_post_view.xml',
],
'installable': False,
'installable': True,
}

View File

@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com)
© 2015-2017 Akretion (http://www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="view_employee_form_leave_inherit" model="ir.ui.view">
<field name="name">hr_holidays_usability.hr.employee.form</field>
@@ -14,16 +13,15 @@
<field name="arch" type="xml">
<!-- too difficult to hide the inside of the Leave group
so I hide the whole group and re-create one -->
<group string="Leaves" position="attributes">
<xpath expr="//field[@name='remaining_leaves']/../.." position="attributes">
<attribute name="invisible">1</attribute>
</group>
<group string="Leaves" position="after">
</xpath>
<xpath expr="//field[@name='remaining_leaves']/../.." position="after">
<group name="holidays" string="Holidays">
<field name="holiday_exclude_mass_allocation"/>
</group>
</group>
</xpath>
</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,28 +1,11 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# © 2015-2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError
from openerp.exceptions import Warning as UserError
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError, UserError
from datetime import datetime
from dateutil.relativedelta import relativedelta
import pytz
@@ -56,8 +39,6 @@ class HrEmployee(models.Model):
class HrHolidays(models.Model):
_inherit = 'hr.holidays'
_order = 'type desc, date_from desc'
# by default : type desc, date_from asc
# Idea :
# For allocation (type = add), we don't change anything:
@@ -161,26 +142,26 @@ class HrHolidays(models.Model):
date_dt += relativedelta(days=1)
return days
@api.one
@api.depends('holiday_type', 'employee_id', 'holiday_status_id')
def _compute_current_leaves(self):
total_allocated_leaves = 0
current_leaves_taken = 0
current_remaining_leaves = 0
if (
self.holiday_type == 'employee' and
self.employee_id and
self.holiday_status_id):
days = self.holiday_status_id.get_days(self.employee_id.id)
total_allocated_leaves =\
days[self.holiday_status_id.id]['max_leaves']
current_leaves_taken =\
days[self.holiday_status_id.id]['leaves_taken']
current_remaining_leaves =\
days[self.holiday_status_id.id]['remaining_leaves']
self.total_allocated_leaves = total_allocated_leaves
self.current_leaves_taken = current_leaves_taken
self.current_remaining_leaves = current_remaining_leaves
for holi in self:
total_allocated_leaves = 0
current_leaves_taken = 0
current_remaining_leaves = 0
if (
holi.holiday_type == 'employee' and
holi.employee_id and
holi.holiday_status_id):
days = holi.holiday_status_id.get_days(holi.employee_id.id)
total_allocated_leaves =\
days[holi.holiday_status_id.id]['max_leaves']
current_leaves_taken =\
days[holi.holiday_status_id.id]['leaves_taken']
current_remaining_leaves =\
days[holi.holiday_status_id.id]['remaining_leaves']
holi.total_allocated_leaves = total_allocated_leaves
holi.current_leaves_taken = current_leaves_taken
holi.current_remaining_leaves = current_remaining_leaves
vacation_date_from = fields.Date(
string='First Day of Vacation', track_visibility='onchange',
@@ -228,10 +209,6 @@ class HrHolidays(models.Model):
limit = fields.Boolean( # pose des pbs de droits
related='holiday_status_id.limit', string='Allow to Override Limit',
readonly=True)
no_email_notification = fields.Boolean(
string='No Email Notification',
help="This field is designed to workaround the fact that you can't "
"pass context in the methods of the workflow")
posted_date = fields.Date(
string='Posted Date', track_visibility='onchange')
number_of_days_temp = fields.Float(string="Number of days")
@@ -242,40 +219,40 @@ class HrHolidays(models.Model):
help="Warning: this title is shown publicly in the "
"calendar. Don't write private/personnal information in this field.")
@api.one
@api.constrains(
'vacation_date_from', 'vacation_date_to', 'holiday_type', 'type')
def _check_vacation_dates(self):
hhpo = self.env['hr.holidays.public']
if self.type == 'remove':
if self.vacation_date_from > self.vacation_date_to:
raise ValidationError(
_('The first day cannot be after the last day !'))
elif (
self.vacation_date_from == self.vacation_date_to and
self.vacation_time_from == self.vacation_time_to):
raise ValidationError(
_("The start of vacation is exactly the "
for holi in self:
if holi.type == 'remove':
if holi.vacation_date_from > holi.vacation_date_to:
raise ValidationError(_(
'The first day cannot be after the last day !'))
elif (
holi.vacation_date_from == holi.vacation_date_to and
holi.vacation_time_from == holi.vacation_time_to):
raise ValidationError(_(
"The start of vacation is exactly the "
"same as the end !"))
date_from_dt = fields.Date.from_string(
self.vacation_date_from)
if date_from_dt.weekday() in (5, 6):
raise ValidationError(
_("The first day of vacation cannot be a "
date_from_dt = fields.Date.from_string(
holi.vacation_date_from)
if date_from_dt.weekday() in (5, 6):
raise ValidationError(_(
"The first day of vacation cannot be a "
"saturday or sunday !"))
date_to_dt = fields.Date.from_string(
self.vacation_date_to)
if date_to_dt.weekday() in (5, 6):
raise ValidationError(
_("The last day of Vacation cannot be a "
date_to_dt = fields.Date.from_string(
holi.vacation_date_to)
if date_to_dt.weekday() in (5, 6):
raise ValidationError(_(
"The last day of Vacation cannot be a "
"saturday or sunday !"))
if hhpo.is_public_holiday(date_from_dt, self.employee_id.id):
raise ValidationError(
_("The first day of vacation cannot be a "
if hhpo.is_public_holiday(date_from_dt, holi.employee_id.id):
raise ValidationError(_(
"The first day of vacation cannot be a "
"bank holiday !"))
if hhpo.is_public_holiday(date_to_dt, self.employee_id.id):
raise ValidationError(
_("The last day of vacation cannot be a "
if hhpo.is_public_holiday(date_to_dt, holi.employee_id.id):
raise ValidationError(_(
"The last day of vacation cannot be a "
"bank holiday !"))
@api.onchange('vacation_date_from', 'vacation_time_from')
@@ -334,15 +311,14 @@ class HrHolidays(models.Model):
self.number_of_days_temp = days
# Neutralize the native on_change on dates
def onchange_date_from(self, cr, uid, ids, date_to, date_from):
def _onchange_date_from(self):
print "_onchange_date_from self=", self
return {}
def onchange_date_to(self, cr, uid, ids, date_to, date_from):
def _onchange_date_to(self):
print "xxxxxxxxxxxxxxx _onchange_date_to self=", self
return {}
# in v8, no more need to inherit check_holidays() as I did in v8
# because it doesn't use number_of_days_temp
# I want to set number_of_days_temp as readonly in the view of leaves
# and, even in v8, we can't write on a readonly field
# So I inherit write and create
@@ -365,7 +341,7 @@ class HrHolidays(models.Model):
return res
@api.multi
def holidays_validate(self):
def action_validate(self):
for holi in self:
if holi.user_id == self.env.user:
if holi.type == 'remove':
@@ -374,36 +350,34 @@ class HrHolidays(models.Model):
% holi.name)
elif (
holi.type == 'add' and
not self.pool['res.users'].has_group(
self._cr, self._uid, 'base.group_hr_manager')):
not self.env.user.has_group(
'hr_holidays.group_hr_holidays_manager')):
raise UserError(_(
"You cannot validate your own Allocation "
"request '%s'.")
% holi.name)
"request '%s'.") % holi.name)
if (
holi.type == 'add' and
holi.holiday_status_id.add_validation_manager and
not self.pool['res.users'].has_group(
self._cr, self._uid, 'base.group_hr_manager')):
not self.env.user.has_group(
'hr_holidays.group_hr_holidays_manager')):
raise UserError(_(
"Allocation request '%s' has a leave type '%s' that "
"can be approved only by an HR Manager.")
% (holi.name, holi.holiday_status_id.name))
res = super(HrHolidays, self).holidays_validate()
return res
return super(HrHolidays, self).action_validate()
@api.multi
def holidays_refuse(self):
def action_refuse(self):
for holi in self:
if (
holi.user_id == self.env.user and
not self.pool['res.users'].has_group(
self._cr, self._uid, 'base.group_hr_manager')):
not self.env.user.has_group(
'hr_holidays.group_hr_holidays_manager')):
raise UserError(_(
"You cannot refuse your own Leave or Allocation "
"holiday request '%s'.")
% holi.name)
return super(HrHolidays, self).holidays_refuse()
return super(HrHolidays, self).action_refuse()
class ResCompany(models.Model):
@@ -411,3 +385,10 @@ class ResCompany(models.Model):
mass_allocation_default_holiday_status_id = fields.Many2one(
'hr.holidays.status', string='Default Leave Type for Mass Allocation')
class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'
mass_allocation_default_holiday_status_id = fields.Many2one(
related='company_id.mass_allocation_default_holiday_status_id')

View File

@@ -1,65 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="ir_actions_server_hr_holidays_confirm_mail" model="ir.actions.server">
<field name="name">Auto-email confirmed leave</field>
<field name="code">context.update({
'wkf_tracker': 'submitted',
'dbname': cr.dbname,
})
if not object.no_email_notification:
template_id=self.pool['ir.model.data'].get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool['email.template'].send_mail(cr, uid, template_id, object.id, context=context)</field>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
<field name="condition">True</field>
</record>
<record id="ir_actions_server_hr_holidays_validate_mail" model="ir.actions.server">
<field name="name">Auto-email validated leave</field>
<field name="code">context.update({
'wkf_tracker': 'validated',
'dbname': cr.dbname,
})
if not object.no_email_notification:
template_id=self.pool['ir.model.data'].get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool['email.template'].send_mail(cr, uid, template_id, object.id, context=context)</field>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
<field name="condition">True</field>
</record>
<record id="ir_actions_server_hr_holidays_refuse_mail" model="ir.actions.server">
<field name="name">Auto-email refused leave</field>
<field name="code">context.update({
'wkf_tracker': 'refused',
'dbname': cr.dbname,
})
if not object.no_email_notification:
template_id=self.pool['ir.model.data'].get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool['email.template'].send_mail(cr, uid, template_id, object.id, context=context)</field>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
<field name="condition">True</field>
</record>
<record id="hr_holidays.act_confirm" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_hr_holidays_confirm_mail"/>
</record>
<record id="hr_holidays.act_validate" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_hr_holidays_validate_mail"/>
</record>
<record id="hr_holidays.act_refuse" model="workflow.activity">
<field name="action_id" ref="ir_actions_server_hr_holidays_refuse_mail"/>
</record>
<record id="email_template_hr_holidays" model="email.template">
<record id="email_template_hr_holidays" model="mail.template">
<field name="name">Holidays email template</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
<field name="email_from">${user.company_id.email}</field>
@@ -110,5 +52,4 @@ Database : ${ctx.get('dbname')}<br/>
]]></field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
© 2015-2017 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<!-- Beware that, in v8, the form view hr_holidays.allocation_company_new
is not used any more (even if it's defined in the XML ; the form view
@@ -61,13 +60,13 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
</group>
</field>
<field name="department_id" position="after">
<field name="posted_date" groups="base.group_hr_manager"/>
<field name="posted_date" groups="hr_holidays.group_hr_holidays_manager"/>
</field>
</field>
</record>
<record id="view_holiday" model="ir.ui.view">
<field name="name">hr_holidays_usability.leave_request_tree</field>
<field name="name">hr_holidays_usability.hr.holidays.tree</field>
<field name="model">hr.holidays</field>
<field name="inherit_id" ref="hr_holidays.view_holiday"/>
<field name="arch" type="xml">
@@ -85,16 +84,14 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
<field name="vacation_date_to"/>
<field name="vacation_time_to"/>
</field>
<field name="holiday_status_id" position="attributes">
<attribute name="invisible">0</attribute>
</field>
<field name="holiday_status_id" position="after">
<field name="posted_date" groups="base.group_hr_manager"/>
<field name="posted_date" groups="hr_holidays.group_hr_holidays_manager"/>
</field>
</field>
</record>
<record id="view_holiday_simple" model="ir.ui.view">
<field name="name">hr_holidays_usability.report_tree</field>
<field name="model">hr.holidays</field>
@@ -129,15 +126,15 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
</field>
</record>
<record id="hr_holiday_graph" model="ir.ui.view">
<field name="name">hr_holidays_usability.hr_holiday_graph</field>
<record id="hr_holiday_pivot" model="ir.ui.view">
<field name="name">hr_holidays_usability.hr_holiday_pivot</field>
<field name="model">hr.holidays</field>
<field name="arch" type="xml">
<graph string="Leave Requests" type="pivot">
<pivot string="Leave Requests">
<field name="employee_id" type="row"/>
<field name="holiday_status_id" type="col"/>
<field name="number_of_days_temp" type="measure"/>
</graph>
</pivot>
</field>
</record>
@@ -171,31 +168,39 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
<field name="sequence" eval="4"/>
</record>
<record id="action_open_ask_holidays_graph" model="ir.actions.act_window.view">
<record id="action_open_ask_holidays_pivot" model="ir.actions.act_window.view">
<field name="sequence" eval="5"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="hr_holiday_graph"/>
<field name="view_mode">pivot</field>
<field name="view_id" ref="hr_holiday_pivot"/>
<field name="act_window_id" ref="hr_holidays.open_ask_holidays"/>
</record>
<!--
<record id="resource_calendar_leaves_cal_first_action" model="ir.actions.act_window">
<field name="name">Leaves Calendar</field>
<field name="res_model">resource.calendar.leaves</field>
<field name="view_mode">calendar,tree,form</field>
</record>
-->
<!-- Warning: when you have mrp installed, there is an ACL that gives write/create access to MRP Users on resource.calendar.leaves You should inherit this ACL with XMLID mrp.access_resource_calendar_leaves_user to give only read access:
mrp.access_resource_calendar_leaves_user,only read access to manufacuting user,resource.model_resource_calendar_leaves,mrp.group_mrp_user,1,0,0,0
-->
<!--
<menuitem id="resource_calendar_leaves_cal_first_menu"
action="resource_calendar_leaves_cal_first_action"
parent="hr_holidays.menu_open_ask_holidays" sequence="100"/>
-->
<menuitem id="hr_holidays_administration_menu"
parent="hr_holidays.menu_hr_holidays_root"
groups="hr_holidays.group_hr_holidays_manager"
name="Administration" sequence="50"/>
<record id="hr_holidays.menu_open_company_allocation" model="ir.ui.menu">
<field name="groups_id" eval="[(4, ref('base.group_hr_user'))]"/>
<field name="groups_id" eval="[(4, ref('hr_holidays.group_hr_holidays_user'))]"/>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,26 +1,9 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# © 2015-2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models, tools
from odoo import fields, models, tools
class HrHolidaysEmployeeCounter(models.Model):
@@ -39,9 +22,9 @@ class HrHolidaysEmployeeCounter(models.Model):
leaves_remaining_posted = fields.Float(string='Posted Remaining Leaves')
allocated_leaves = fields.Float(string='Allocated Leaves')
def init(self, cr):
tools.drop_view_if_exists(cr, 'hr_holidays_employee_counter')
cr.execute("""
def init(self):
tools.drop_view_if_exists(self._cr, 'hr_holidays_employee_counter')
self._cr.execute("""
CREATE or REPLACE view hr_holidays_employee_counter AS (
SELECT
min(hh.id) AS id,

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="hr_holidays_employee_counter_tree" model="ir.ui.view">
<field name="name">hr.holidays.employee.counter.tree</field>
@@ -44,8 +43,7 @@
<menuitem id="hr_holidays_employee_counter_menu"
action="hr_holidays_employee_counter_action"
parent="hr_holidays.menu_open_ask_holidays"/>
parent="hr_holidays.menu_hr_holidays_my_leaves"/>
</data>
</openerp>
</odoo>

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_company_form" model="ir.ui.view">
<field name="name">hr_holidays_usability.res.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<group name="account_grp" position="after">
<group string="Leaves" name="holidays">
<field name="mass_allocation_default_holiday_status_id"/>
</group>
</group>
</field>
</record>
</data>
</openerp>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<odoo noupdate="0">
<!--
Employee : only see his holidays
@@ -19,14 +18,14 @@ Manager = person that administrates the holidays process : can see everything, d
<field name="name">My Holiday Counter and Subordinates</field>
<field name="model_id" ref="model_hr_holidays_employee_counter"/>
<field name="domain_force">['|', ('employee_id.user_id','=',user.id), ('employee_id','child_of',user.employee_ids.ids)]</field>
<field name="groups" eval="[(4, ref('base.group_hr_user'))]"/>
<field name="groups" eval="[(4, ref('hr_holidays.group_hr_holidays_user'))]"/>
</record>
<record id="hr_holidays_counter_see_all" model="ir.rule">
<field name="name">All Holiday Counters</field>
<field name="model_id" ref="model_hr_holidays_employee_counter"/>
<field name="domain_force">[(1,'=',1)]</field>
<field name="groups" eval="[(6, 0, [ref('base.group_hr_manager')])]"/>
<field name="groups" eval="[(6, 0, [ref('hr_holidays.group_hr_holidays_manager')])]"/>
</record>
<!-- inherit native ir.rule ; Officer can see the holidays of his subordinates, not all employees -->
@@ -38,8 +37,7 @@ Manager = person that administrates the holidays process : can see everything, d
<field name="name">HR Manager can see all Holidays</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
<field name="domain_force">[(1,'=',1)]</field>
<field name="groups" eval="[(4, ref('base.group_hr_manager'))]"/>
<field name="groups" eval="[(4, ref('hr_holidays.group_hr_holidays_manager'))]"/>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,27 +1,10 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# © 2015-2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api, workflow, _
from openerp.exceptions import Warning
from odoo import models, fields, api, workflow, _
from odoo.exceptions import UserError
class HrHolidaysMassAllocation(models.TransientModel):
@@ -61,11 +44,11 @@ class HrHolidaysMassAllocation(models.TransientModel):
def run(self):
self.ensure_one()
if not self.number_of_days:
raise Warning(
_('You must set a value for the number of days.'))
raise UserError(_(
'You must set a value for the number of days.'))
if not self.employee_ids:
raise Warning(
_('You must select at least one employee.'))
raise UserError(_(
'You must select at least one employee.'))
alloc_hol_ids = []
hho = self.env['hr.holidays']
auto_approve = self.auto_approve
@@ -77,11 +60,10 @@ class HrHolidaysMassAllocation(models.TransientModel):
'type': 'add',
'holiday_type': 'employee',
'holiday_status_id': self.holiday_status_id.id,
'no_email_notification': True,
})
if auto_approve:
workflow.trg_validate(
self._uid, 'hr.holidays', hol.id, 'validate', self._cr)
# TODO: handle the no_email_notification
hol.action_validate()
alloc_hol_ids.append(hol.id)
action = self.env['ir.actions.act_window'].for_xml_id(
'hr_holidays', 'open_allocation_holidays')

View File

@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
© 2015-2017 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="hr_holidays_mass_allocation_form" model="ir.ui.view">
<field name="name">hr_holidays_mass_allocation_form</field>
@@ -38,8 +37,7 @@
<menuitem id="hr_holidays_mass_allocation_menu"
action="hr_holidays_mass_allocation_action"
parent="hr_holidays.menu_open_ask_holidays"
groups="base.group_hr_manager"/>
parent="hr_holidays_administration_menu"
groups="hr_holidays.group_hr_holidays_manager"/>
</data>
</openerp>
</odoo>

View File

@@ -1,27 +1,10 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# © 2015-2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api, _
from openerp.exceptions import Warning
from odoo import models, fields, api, _
from odoo.exceptions import UserError
class HrHolidaysPost(models.TransientModel):
@@ -74,16 +57,15 @@ class HrHolidaysPost(models.TransientModel):
holidays_to_post = self.holidays_to_post_ids
today = fields.Date.context_today(self)
if not self.holidays_to_post_ids:
raise Warning(
_('No leave request to post.'))
raise UserError(_('No leave request to post.'))
self.holidays_to_post_ids.write({'posted_date': today})
view_id = self.env.ref('hr_holidays_usability.hr_holiday_graph').id
view_id = self.env.ref('hr_holidays_usability.hr_holiday_pivot').id
action = {
'name': _('Leave Requests'),
'res_model': 'hr.holidays',
'type': 'ir.actions.act_window',
'domain': [('id', 'in', holidays_to_post.ids)],
'view_mode': 'graph',
'view_mode': 'pivot',
'view_id': view_id,
}
return action

View File

@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
© 2015-2017 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="hr_holidays_post_form" model="ir.ui.view">
<field name="name">hr_holidays_post_form</field>
<field name="model">hr.holidays.post</field>
<field name="arch" type="xml">
<form string="Post Leaves" version="7.0">
<form string="Post Leaves">
<group name="main" string="Leave Requests to Post">
<field name="state" invisible="1"/>
<field name="before_date" states="draft"/>
@@ -40,8 +39,7 @@
<menuitem id="hr_holidays_post_menu"
action="hr_holidays_post_action"
parent="hr_holidays.menu_open_ask_holidays"
groups="base.group_hr_manager"/>
parent="hr_holidays_administration_menu"
groups="hr_holidays.group_hr_holidays_manager"/>
</data>
</openerp>
</odoo>

View File

@@ -2,3 +2,4 @@
from . import purchase
from . import product
from . import partner

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
class ResPartner(models.Model):
_inherit = 'res.partner'
purchase_warn = fields.Selection(track_visibility='onchange')
# Fix an access right issue when accessing partner form without being
# a member of the purchase/User group
@api.multi
def _purchase_invoice_count(self):
poo = self.env['purchase.order']
aio = self.env['account.invoice']
for partner in self:
try:
partner.purchase_order_count = poo.search_count(
[('partner_id', 'child_of', partner.id)])
except:
pass
try:
partner.supplier_invoice_count = aio.search_count([
('partner_id', 'child_of', partner.id),
('type', '=', 'in_invoice')])
except:
pass

View File

@@ -9,3 +9,4 @@ class ProductTemplate(models.Model):
_inherit = 'product.template'
purchase_method = fields.Selection(track_visibility='onchange')
purchase_line_warn = fields.Selection(track_visibility='onchange')

View File

@@ -41,26 +41,3 @@ class StockPicking(models.Model):
purchase_id = fields.Many2one(
related='move_lines.purchase_line_id.order_id', readonly=True,
string='Purchase Order')
class ResPartner(models.Model):
_inherit = 'res.partner'
# Fix an access right issue when accessing partner form without being
# a member of the purchase/User group
@api.multi
def _purchase_invoice_count(self):
poo = self.env['purchase.order']
aio = self.env['account.invoice']
for partner in self:
try:
partner.purchase_order_count = poo.search_count(
[('partner_id', 'child_of', partner.id)])
except:
pass
try:
partner.supplier_invoice_count = aio.search_count([
('partner_id', 'child_of', partner.id),
('type', '=', 'in_invoice')])
except:
pass

View File

@@ -2,3 +2,4 @@
from . import sale
from . import product
from . import partner

11
sale_usability/partner.py Normal file
View File

@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class ResPartner(models.Model):
_inherit = 'res.partner'
sale_warn = fields.Selection(track_visibility='onchange')

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
@@ -11,3 +11,4 @@ class ProductTemplate(models.Model):
track_service = fields.Selection(track_visibility='onchange')
expense_policy = fields.Selection(track_visibility='onchange')
invoice_policy = fields.Selection(track_visibility='onchange')
sale_line_warn = fields.Selection(track_visibility='onchange')

View File

@@ -3,3 +3,4 @@
from . import stock
from . import procurement
from . import product
from . import partner

View File

@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class ResPartner(models.Model):
_inherit = 'res.partner'
picking_warn = fields.Selection(track_visibility='onchange')