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 -*- # -*- coding: utf-8 -*-
from . import account 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 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015-2017 Akretion (http://www.akretion.com)
# # @author Alexis de Lattre <alexis.delattre@akretion.com>
# HR Holidays Usability module for Odoo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# 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/>.
#
##############################################################################
{ {
'name': 'HR Holidays Usability', 'name': 'HR Holidays Usability',
'version': '0.1', 'version': '10.0.1.0.0',
'category': 'Human Resources', 'category': 'Human Resources',
'license': 'AGPL-3', 'license': 'AGPL-3',
'summary': 'Better usability for the management of holidays', 'summary': 'Better usability for the management of holidays',
'description': '',
'author': 'Akretion', 'author': 'Akretion',
'website': 'http://www.akretion.com', 'website': 'http://www.akretion.com',
'depends': ['hr_holidays', 'hr_public_holidays'], 'depends': ['hr_holidays', 'hr_public_holidays'],
'data': [ 'data': [
'wizard/hr_holidays_mass_allocation_view.xml',
'wizard/hr_holidays_post_view.xml',
'report/hr_holidays_employee_counter_view.xml', 'report/hr_holidays_employee_counter_view.xml',
'hr_holidays_view.xml', 'hr_holidays_view.xml',
'hr_holidays_mail.xml', 'hr_holidays_mail.xml',
'res_company_view.xml', 'base_config_settings_view.xml',
'hr_employee_view.xml', 'hr_employee_view.xml',
'security/holiday_security.xml', 'security/holiday_security.xml',
'security/ir.model.access.csv', '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"?> <?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> @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> <odoo>
<data>
<record id="view_employee_form_leave_inherit" model="ir.ui.view"> <record id="view_employee_form_leave_inherit" model="ir.ui.view">
<field name="name">hr_holidays_usability.hr.employee.form</field> <field name="name">hr_holidays_usability.hr.employee.form</field>
@@ -14,16 +13,15 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- too difficult to hide the inside of the Leave group <!-- too difficult to hide the inside of the Leave group
so I hide the whole group and re-create one --> 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> <attribute name="invisible">1</attribute>
</group> </xpath>
<group string="Leaves" position="after"> <xpath expr="//field[@name='remaining_leaves']/../.." position="after">
<group name="holidays" string="Holidays"> <group name="holidays" string="Holidays">
<field name="holiday_exclude_mass_allocation"/> <field name="holiday_exclude_mass_allocation"/>
</group> </group>
</group> </xpath>
</field> </field>
</record> </record>
</data> </odoo>
</openerp>

View File

@@ -1,28 +1,11 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015-2017 Akretion (http://www.akretion.com)
# # @author Alexis de Lattre <alexis.delattre@akretion.com>
# HR Holidays Usability module for Odoo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# 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/>.
#
##############################################################################
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError from odoo import models, fields, api, _
from openerp.exceptions import Warning as UserError from odoo.exceptions import ValidationError, UserError
from datetime import datetime from datetime import datetime
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
import pytz import pytz
@@ -56,8 +39,6 @@ class HrEmployee(models.Model):
class HrHolidays(models.Model): class HrHolidays(models.Model):
_inherit = 'hr.holidays' _inherit = 'hr.holidays'
_order = 'type desc, date_from desc'
# by default : type desc, date_from asc
# Idea : # Idea :
# For allocation (type = add), we don't change anything: # For allocation (type = add), we don't change anything:
@@ -161,26 +142,26 @@ class HrHolidays(models.Model):
date_dt += relativedelta(days=1) date_dt += relativedelta(days=1)
return days return days
@api.one
@api.depends('holiday_type', 'employee_id', 'holiday_status_id') @api.depends('holiday_type', 'employee_id', 'holiday_status_id')
def _compute_current_leaves(self): def _compute_current_leaves(self):
total_allocated_leaves = 0 for holi in self:
current_leaves_taken = 0 total_allocated_leaves = 0
current_remaining_leaves = 0 current_leaves_taken = 0
if ( current_remaining_leaves = 0
self.holiday_type == 'employee' and if (
self.employee_id and holi.holiday_type == 'employee' and
self.holiday_status_id): holi.employee_id and
days = self.holiday_status_id.get_days(self.employee_id.id) holi.holiday_status_id):
total_allocated_leaves =\ days = holi.holiday_status_id.get_days(holi.employee_id.id)
days[self.holiday_status_id.id]['max_leaves'] total_allocated_leaves =\
current_leaves_taken =\ days[holi.holiday_status_id.id]['max_leaves']
days[self.holiday_status_id.id]['leaves_taken'] current_leaves_taken =\
current_remaining_leaves =\ days[holi.holiday_status_id.id]['leaves_taken']
days[self.holiday_status_id.id]['remaining_leaves'] current_remaining_leaves =\
self.total_allocated_leaves = total_allocated_leaves days[holi.holiday_status_id.id]['remaining_leaves']
self.current_leaves_taken = current_leaves_taken holi.total_allocated_leaves = total_allocated_leaves
self.current_remaining_leaves = current_remaining_leaves holi.current_leaves_taken = current_leaves_taken
holi.current_remaining_leaves = current_remaining_leaves
vacation_date_from = fields.Date( vacation_date_from = fields.Date(
string='First Day of Vacation', track_visibility='onchange', string='First Day of Vacation', track_visibility='onchange',
@@ -228,10 +209,6 @@ class HrHolidays(models.Model):
limit = fields.Boolean( # pose des pbs de droits limit = fields.Boolean( # pose des pbs de droits
related='holiday_status_id.limit', string='Allow to Override Limit', related='holiday_status_id.limit', string='Allow to Override Limit',
readonly=True) 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( posted_date = fields.Date(
string='Posted Date', track_visibility='onchange') string='Posted Date', track_visibility='onchange')
number_of_days_temp = fields.Float(string="Number of days") 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 " help="Warning: this title is shown publicly in the "
"calendar. Don't write private/personnal information in this field.") "calendar. Don't write private/personnal information in this field.")
@api.one
@api.constrains( @api.constrains(
'vacation_date_from', 'vacation_date_to', 'holiday_type', 'type') 'vacation_date_from', 'vacation_date_to', 'holiday_type', 'type')
def _check_vacation_dates(self): def _check_vacation_dates(self):
hhpo = self.env['hr.holidays.public'] hhpo = self.env['hr.holidays.public']
if self.type == 'remove': for holi in self:
if self.vacation_date_from > self.vacation_date_to: if holi.type == 'remove':
raise ValidationError( if holi.vacation_date_from > holi.vacation_date_to:
_('The first day cannot be after the last day !')) raise ValidationError(_(
elif ( 'The first day cannot be after the last day !'))
self.vacation_date_from == self.vacation_date_to and elif (
self.vacation_time_from == self.vacation_time_to): holi.vacation_date_from == holi.vacation_date_to and
raise ValidationError( holi.vacation_time_from == holi.vacation_time_to):
_("The start of vacation is exactly the " raise ValidationError(_(
"The start of vacation is exactly the "
"same as the end !")) "same as the end !"))
date_from_dt = fields.Date.from_string( date_from_dt = fields.Date.from_string(
self.vacation_date_from) holi.vacation_date_from)
if date_from_dt.weekday() in (5, 6): if date_from_dt.weekday() in (5, 6):
raise ValidationError( raise ValidationError(_(
_("The first day of vacation cannot be a " "The first day of vacation cannot be a "
"saturday or sunday !")) "saturday or sunday !"))
date_to_dt = fields.Date.from_string( date_to_dt = fields.Date.from_string(
self.vacation_date_to) holi.vacation_date_to)
if date_to_dt.weekday() in (5, 6): if date_to_dt.weekday() in (5, 6):
raise ValidationError( raise ValidationError(_(
_("The last day of Vacation cannot be a " "The last day of Vacation cannot be a "
"saturday or sunday !")) "saturday or sunday !"))
if hhpo.is_public_holiday(date_from_dt, self.employee_id.id): if hhpo.is_public_holiday(date_from_dt, holi.employee_id.id):
raise ValidationError( raise ValidationError(_(
_("The first day of vacation cannot be a " "The first day of vacation cannot be a "
"bank holiday !")) "bank holiday !"))
if hhpo.is_public_holiday(date_to_dt, self.employee_id.id): if hhpo.is_public_holiday(date_to_dt, holi.employee_id.id):
raise ValidationError( raise ValidationError(_(
_("The last day of vacation cannot be a " "The last day of vacation cannot be a "
"bank holiday !")) "bank holiday !"))
@api.onchange('vacation_date_from', 'vacation_time_from') @api.onchange('vacation_date_from', 'vacation_time_from')
@@ -334,15 +311,14 @@ class HrHolidays(models.Model):
self.number_of_days_temp = days self.number_of_days_temp = days
# Neutralize the native on_change on dates # 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 {} 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 {} 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 # 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 # and, even in v8, we can't write on a readonly field
# So I inherit write and create # So I inherit write and create
@@ -365,7 +341,7 @@ class HrHolidays(models.Model):
return res return res
@api.multi @api.multi
def holidays_validate(self): def action_validate(self):
for holi in self: for holi in self:
if holi.user_id == self.env.user: if holi.user_id == self.env.user:
if holi.type == 'remove': if holi.type == 'remove':
@@ -374,36 +350,34 @@ class HrHolidays(models.Model):
% holi.name) % holi.name)
elif ( elif (
holi.type == 'add' and holi.type == 'add' and
not self.pool['res.users'].has_group( not self.env.user.has_group(
self._cr, self._uid, 'base.group_hr_manager')): 'hr_holidays.group_hr_holidays_manager')):
raise UserError(_( raise UserError(_(
"You cannot validate your own Allocation " "You cannot validate your own Allocation "
"request '%s'.") "request '%s'.") % holi.name)
% holi.name)
if ( if (
holi.type == 'add' and holi.type == 'add' and
holi.holiday_status_id.add_validation_manager and holi.holiday_status_id.add_validation_manager and
not self.pool['res.users'].has_group( not self.env.user.has_group(
self._cr, self._uid, 'base.group_hr_manager')): 'hr_holidays.group_hr_holidays_manager')):
raise UserError(_( raise UserError(_(
"Allocation request '%s' has a leave type '%s' that " "Allocation request '%s' has a leave type '%s' that "
"can be approved only by an HR Manager.") "can be approved only by an HR Manager.")
% (holi.name, holi.holiday_status_id.name)) % (holi.name, holi.holiday_status_id.name))
res = super(HrHolidays, self).holidays_validate() return super(HrHolidays, self).action_validate()
return res
@api.multi @api.multi
def holidays_refuse(self): def action_refuse(self):
for holi in self: for holi in self:
if ( if (
holi.user_id == self.env.user and holi.user_id == self.env.user and
not self.pool['res.users'].has_group( not self.env.user.has_group(
self._cr, self._uid, 'base.group_hr_manager')): 'hr_holidays.group_hr_holidays_manager')):
raise UserError(_( raise UserError(_(
"You cannot refuse your own Leave or Allocation " "You cannot refuse your own Leave or Allocation "
"holiday request '%s'.") "holiday request '%s'.")
% holi.name) % holi.name)
return super(HrHolidays, self).holidays_refuse() return super(HrHolidays, self).action_refuse()
class ResCompany(models.Model): class ResCompany(models.Model):
@@ -411,3 +385,10 @@ class ResCompany(models.Model):
mass_allocation_default_holiday_status_id = fields.Many2one( mass_allocation_default_holiday_status_id = fields.Many2one(
'hr.holidays.status', string='Default Leave Type for Mass Allocation') '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"?> <?xml version="1.0" encoding="utf-8"?>
<openerp> <odoo>
<data>
<record id="ir_actions_server_hr_holidays_confirm_mail" model="ir.actions.server"> <record id="email_template_hr_holidays" model="mail.template">
<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">
<field name="name">Holidays email template</field> <field name="name">Holidays email template</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/> <field name="model_id" ref="hr_holidays.model_hr_holidays"/>
<field name="email_from">${user.company_id.email}</field> <field name="email_from">${user.company_id.email}</field>
@@ -110,5 +52,4 @@ Database : ${ctx.get('dbname')}<br/>
]]></field> ]]></field>
</record> </record>
</data> </odoo>
</openerp>

View File

@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?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> @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> <odoo>
<data>
<!-- Beware that, in v8, the form view hr_holidays.allocation_company_new <!-- 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 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> </group>
</field> </field>
<field name="department_id" position="after"> <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>
</field> </field>
</record> </record>
<record id="view_holiday" model="ir.ui.view"> <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="model">hr.holidays</field>
<field name="inherit_id" ref="hr_holidays.view_holiday"/> <field name="inherit_id" ref="hr_holidays.view_holiday"/>
<field name="arch" type="xml"> <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_date_to"/>
<field name="vacation_time_to"/> <field name="vacation_time_to"/>
</field> </field>
<field name="holiday_status_id" position="attributes">
<attribute name="invisible">0</attribute>
</field>
<field name="holiday_status_id" position="after"> <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>
</field> </field>
</record> </record>
<record id="view_holiday_simple" model="ir.ui.view"> <record id="view_holiday_simple" model="ir.ui.view">
<field name="name">hr_holidays_usability.report_tree</field> <field name="name">hr_holidays_usability.report_tree</field>
<field name="model">hr.holidays</field> <field name="model">hr.holidays</field>
@@ -129,15 +126,15 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
</field> </field>
</record> </record>
<record id="hr_holiday_graph" model="ir.ui.view"> <record id="hr_holiday_pivot" model="ir.ui.view">
<field name="name">hr_holidays_usability.hr_holiday_graph</field> <field name="name">hr_holidays_usability.hr_holiday_pivot</field>
<field name="model">hr.holidays</field> <field name="model">hr.holidays</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<graph string="Leave Requests" type="pivot"> <pivot string="Leave Requests">
<field name="employee_id" type="row"/> <field name="employee_id" type="row"/>
<field name="holiday_status_id" type="col"/> <field name="holiday_status_id" type="col"/>
<field name="number_of_days_temp" type="measure"/> <field name="number_of_days_temp" type="measure"/>
</graph> </pivot>
</field> </field>
</record> </record>
@@ -171,31 +168,39 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
<field name="sequence" eval="4"/> <field name="sequence" eval="4"/>
</record> </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="sequence" eval="5"/>
<field name="view_mode">graph</field> <field name="view_mode">pivot</field>
<field name="view_id" ref="hr_holiday_graph"/> <field name="view_id" ref="hr_holiday_pivot"/>
<field name="act_window_id" ref="hr_holidays.open_ask_holidays"/> <field name="act_window_id" ref="hr_holidays.open_ask_holidays"/>
</record> </record>
<!--
<record id="resource_calendar_leaves_cal_first_action" model="ir.actions.act_window"> <record id="resource_calendar_leaves_cal_first_action" model="ir.actions.act_window">
<field name="name">Leaves Calendar</field> <field name="name">Leaves Calendar</field>
<field name="res_model">resource.calendar.leaves</field> <field name="res_model">resource.calendar.leaves</field>
<field name="view_mode">calendar,tree,form</field> <field name="view_mode">calendar,tree,form</field>
</record> </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: <!-- 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 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" <menuitem id="resource_calendar_leaves_cal_first_menu"
action="resource_calendar_leaves_cal_first_action" action="resource_calendar_leaves_cal_first_action"
parent="hr_holidays.menu_open_ask_holidays" sequence="100"/> 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"> <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> </record>
</data> </odoo>
</openerp>

View File

@@ -1,26 +1,9 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015-2017 Akretion (http://www.akretion.com)
# # @author Alexis de Lattre <alexis.delattre@akretion.com>
# HR Holidays Usability module for Odoo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# 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/>.
#
##############################################################################
from openerp import fields, models, tools from odoo import fields, models, tools
class HrHolidaysEmployeeCounter(models.Model): class HrHolidaysEmployeeCounter(models.Model):
@@ -39,9 +22,9 @@ class HrHolidaysEmployeeCounter(models.Model):
leaves_remaining_posted = fields.Float(string='Posted Remaining Leaves') leaves_remaining_posted = fields.Float(string='Posted Remaining Leaves')
allocated_leaves = fields.Float(string='Allocated Leaves') allocated_leaves = fields.Float(string='Allocated Leaves')
def init(self, cr): def init(self):
tools.drop_view_if_exists(cr, 'hr_holidays_employee_counter') tools.drop_view_if_exists(self._cr, 'hr_holidays_employee_counter')
cr.execute(""" self._cr.execute("""
CREATE or REPLACE view hr_holidays_employee_counter AS ( CREATE or REPLACE view hr_holidays_employee_counter AS (
SELECT SELECT
min(hh.id) AS id, min(hh.id) AS id,

View File

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

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"?> <?xml version="1.0" encoding="utf-8"?>
<openerp> <odoo noupdate="0">
<data noupdate="0">
<!-- <!--
Employee : only see his holidays 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="name">My Holiday Counter and Subordinates</field>
<field name="model_id" ref="model_hr_holidays_employee_counter"/> <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="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>
<record id="hr_holidays_counter_see_all" model="ir.rule"> <record id="hr_holidays_counter_see_all" model="ir.rule">
<field name="name">All Holiday Counters</field> <field name="name">All Holiday Counters</field>
<field name="model_id" ref="model_hr_holidays_employee_counter"/> <field name="model_id" ref="model_hr_holidays_employee_counter"/>
<field name="domain_force">[(1,'=',1)]</field> <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> </record>
<!-- inherit native ir.rule ; Officer can see the holidays of his subordinates, not all employees --> <!-- 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="name">HR Manager can see all Holidays</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/> <field name="model_id" ref="hr_holidays.model_hr_holidays"/>
<field name="domain_force">[(1,'=',1)]</field> <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> </record>
</data> </odoo>
</openerp>

View File

@@ -1,27 +1,10 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015-2017 Akretion (http://www.akretion.com)
# # @author Alexis de Lattre <alexis.delattre@akretion.com>
# HR Holidays Usability module for Odoo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# 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/>.
#
##############################################################################
from openerp import models, fields, api, workflow, _ from odoo import models, fields, api, workflow, _
from openerp.exceptions import Warning from odoo.exceptions import UserError
class HrHolidaysMassAllocation(models.TransientModel): class HrHolidaysMassAllocation(models.TransientModel):
@@ -61,11 +44,11 @@ class HrHolidaysMassAllocation(models.TransientModel):
def run(self): def run(self):
self.ensure_one() self.ensure_one()
if not self.number_of_days: if not self.number_of_days:
raise Warning( raise UserError(_(
_('You must set a value for the number of days.')) 'You must set a value for the number of days.'))
if not self.employee_ids: if not self.employee_ids:
raise Warning( raise UserError(_(
_('You must select at least one employee.')) 'You must select at least one employee.'))
alloc_hol_ids = [] alloc_hol_ids = []
hho = self.env['hr.holidays'] hho = self.env['hr.holidays']
auto_approve = self.auto_approve auto_approve = self.auto_approve
@@ -77,11 +60,10 @@ class HrHolidaysMassAllocation(models.TransientModel):
'type': 'add', 'type': 'add',
'holiday_type': 'employee', 'holiday_type': 'employee',
'holiday_status_id': self.holiday_status_id.id, 'holiday_status_id': self.holiday_status_id.id,
'no_email_notification': True,
}) })
if auto_approve: if auto_approve:
workflow.trg_validate( # TODO: handle the no_email_notification
self._uid, 'hr.holidays', hol.id, 'validate', self._cr) hol.action_validate()
alloc_hol_ids.append(hol.id) alloc_hol_ids.append(hol.id)
action = self.env['ir.actions.act_window'].for_xml_id( action = self.env['ir.actions.act_window'].for_xml_id(
'hr_holidays', 'open_allocation_holidays') 'hr_holidays', 'open_allocation_holidays')

View File

@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?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> @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> <odoo>
<data>
<record id="hr_holidays_mass_allocation_form" model="ir.ui.view"> <record id="hr_holidays_mass_allocation_form" model="ir.ui.view">
<field name="name">hr_holidays_mass_allocation_form</field> <field name="name">hr_holidays_mass_allocation_form</field>
@@ -38,8 +37,7 @@
<menuitem id="hr_holidays_mass_allocation_menu" <menuitem id="hr_holidays_mass_allocation_menu"
action="hr_holidays_mass_allocation_action" action="hr_holidays_mass_allocation_action"
parent="hr_holidays.menu_open_ask_holidays" parent="hr_holidays_administration_menu"
groups="base.group_hr_manager"/> groups="hr_holidays.group_hr_holidays_manager"/>
</data> </odoo>
</openerp>

View File

@@ -1,27 +1,10 @@
# -*- encoding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## # © 2015-2017 Akretion (http://www.akretion.com)
# # @author Alexis de Lattre <alexis.delattre@akretion.com>
# HR Holidays Usability module for Odoo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# 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/>.
#
##############################################################################
from openerp import models, fields, api, _ from odoo import models, fields, api, _
from openerp.exceptions import Warning from odoo.exceptions import UserError
class HrHolidaysPost(models.TransientModel): class HrHolidaysPost(models.TransientModel):
@@ -74,16 +57,15 @@ class HrHolidaysPost(models.TransientModel):
holidays_to_post = self.holidays_to_post_ids holidays_to_post = self.holidays_to_post_ids
today = fields.Date.context_today(self) today = fields.Date.context_today(self)
if not self.holidays_to_post_ids: if not self.holidays_to_post_ids:
raise Warning( raise UserError(_('No leave request to post.'))
_('No leave request to post.'))
self.holidays_to_post_ids.write({'posted_date': today}) 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 = { action = {
'name': _('Leave Requests'), 'name': _('Leave Requests'),
'res_model': 'hr.holidays', 'res_model': 'hr.holidays',
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'domain': [('id', 'in', holidays_to_post.ids)], 'domain': [('id', 'in', holidays_to_post.ids)],
'view_mode': 'graph', 'view_mode': 'pivot',
'view_id': view_id, 'view_id': view_id,
} }
return action return action

View File

@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?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> @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> <odoo>
<data>
<record id="hr_holidays_post_form" model="ir.ui.view"> <record id="hr_holidays_post_form" model="ir.ui.view">
<field name="name">hr_holidays_post_form</field> <field name="name">hr_holidays_post_form</field>
<field name="model">hr.holidays.post</field> <field name="model">hr.holidays.post</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Post Leaves" version="7.0"> <form string="Post Leaves">
<group name="main" string="Leave Requests to Post"> <group name="main" string="Leave Requests to Post">
<field name="state" invisible="1"/> <field name="state" invisible="1"/>
<field name="before_date" states="draft"/> <field name="before_date" states="draft"/>
@@ -40,8 +39,7 @@
<menuitem id="hr_holidays_post_menu" <menuitem id="hr_holidays_post_menu"
action="hr_holidays_post_action" action="hr_holidays_post_action"
parent="hr_holidays.menu_open_ask_holidays" parent="hr_holidays_administration_menu"
groups="base.group_hr_manager"/> groups="hr_holidays.group_hr_holidays_manager"/>
</data> </odoo>
</openerp>

View File

@@ -2,3 +2,4 @@
from . import purchase from . import purchase
from . import product 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' _inherit = 'product.template'
purchase_method = fields.Selection(track_visibility='onchange') 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( purchase_id = fields.Many2one(
related='move_lines.purchase_line_id.order_id', readonly=True, related='move_lines.purchase_line_id.order_id', readonly=True,
string='Purchase Order') 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 sale
from . import product 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 -*- # -*- 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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields from odoo import models, fields
@@ -11,3 +11,4 @@ class ProductTemplate(models.Model):
track_service = fields.Selection(track_visibility='onchange') track_service = fields.Selection(track_visibility='onchange')
expense_policy = fields.Selection(track_visibility='onchange') expense_policy = fields.Selection(track_visibility='onchange')
invoice_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 stock
from . import procurement from . import procurement
from . import product 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')