From 348e0205a06ae2a5b68a4ec335cd7688202b6db7 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 5 Apr 2017 19:22:01 +0200 Subject: [PATCH] Add traking on warn fields WORK IN PROGRESS: port hr_holidays_usability --- account_usability/__init__.py | 1 + account_usability/partner.py | 11 ++ hr_holidays_usability/__manifest__.py | 35 +--- hr_holidays_usability/hr_employee_view.xml | 18 +- hr_holidays_usability/hr_holidays.py | 165 ++++++++---------- hr_holidays_usability/hr_holidays_mail.xml | 65 +------ hr_holidays_usability/hr_holidays_view.xml | 49 +++--- .../report/hr_holidays_employee_counter.py | 33 +--- .../hr_holidays_employee_counter_view.xml | 8 +- hr_holidays_usability/res_config_view.xml | 24 --- .../security/holiday_security.xml | 12 +- .../wizard/hr_holidays_mass_allocation.py | 42 ++--- .../hr_holidays_mass_allocation_view.xml | 16 +- .../wizard/hr_holidays_post.py | 36 +--- .../wizard/hr_holidays_post_view.xml | 18 +- purchase_usability/__init__.py | 1 + purchase_usability/partner.py | 30 ++++ purchase_usability/product.py | 1 + purchase_usability/purchase.py | 23 --- sale_usability/__init__.py | 1 + sale_usability/partner.py | 11 ++ sale_usability/product.py | 3 +- stock_usability/__init__.py | 1 + stock_usability/partner.py | 11 ++ 24 files changed, 241 insertions(+), 374 deletions(-) create mode 100644 account_usability/partner.py delete mode 100644 hr_holidays_usability/res_config_view.xml create mode 100644 purchase_usability/partner.py create mode 100644 sale_usability/partner.py create mode 100644 stock_usability/partner.py diff --git a/account_usability/__init__.py b/account_usability/__init__.py index 300089b..0b72ffe 100644 --- a/account_usability/__init__.py +++ b/account_usability/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from . import account +from . import partner diff --git a/account_usability/partner.py b/account_usability/partner.py new file mode 100644 index 0000000..03b6e9a --- /dev/null +++ b/account_usability/partner.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# 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') diff --git a/hr_holidays_usability/__manifest__.py b/hr_holidays_usability/__manifest__.py index 510e332..e53d520 100644 --- a/hr_holidays_usability/__manifest__.py +++ b/hr_holidays_usability/__manifest__.py @@ -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 -# -# 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 . -# -############################################################################## - +# © 2015-2017 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# 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, } diff --git a/hr_holidays_usability/hr_employee_view.xml b/hr_holidays_usability/hr_employee_view.xml index 7bef418..2815933 100644 --- a/hr_holidays_usability/hr_employee_view.xml +++ b/hr_holidays_usability/hr_employee_view.xml @@ -1,11 +1,10 @@ - - + hr_holidays_usability.hr.employee.form @@ -14,16 +13,15 @@ - + 1 - - + + - + - - + diff --git a/hr_holidays_usability/hr_holidays.py b/hr_holidays_usability/hr_holidays.py index a3a0365..13e9f6f 100644 --- a/hr_holidays_usability/hr_holidays.py +++ b/hr_holidays_usability/hr_holidays.py @@ -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 -# -# 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 . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015-2017 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# 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') diff --git a/hr_holidays_usability/hr_holidays_mail.xml b/hr_holidays_usability/hr_holidays_mail.xml index 38e16f5..49f0b7f 100644 --- a/hr_holidays_usability/hr_holidays_mail.xml +++ b/hr_holidays_usability/hr_holidays_mail.xml @@ -1,65 +1,7 @@ - - + - - Auto-email confirmed leave - 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) - code - ir.actions.server - - True - - - - Auto-email validated leave - 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) - code - ir.actions.server - - True - - - - Auto-email refused leave - 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) - code - ir.actions.server - - True - - - - - - - - - - - - - - - + Holidays email template ${user.company_id.email} @@ -110,5 +52,4 @@ Database : ${ctx.get('dbname')}
]]>
-
-
+ diff --git a/hr_holidays_usability/hr_holidays_view.xml b/hr_holidays_usability/hr_holidays_view.xml index b105658..9cb6b9a 100644 --- a/hr_holidays_usability/hr_holidays_view.xml +++ b/hr_holidays_usability/hr_holidays_view.xml @@ -1,12 +1,11 @@ - - + - + - hr_holidays_usability.leave_request_tree + hr_holidays_usability.hr.holidays.tree hr.holidays @@ -85,16 +84,14 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> - - 0 - - + + hr_holidays_usability.report_tree hr.holidays @@ -129,15 +126,15 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> - - hr_holidays_usability.hr_holiday_graph + + hr_holidays_usability.hr_holiday_pivot hr.holidays - + - + @@ -171,31 +168,39 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> - + - graph - + pivot + + + - + + + - + - - + diff --git a/hr_holidays_usability/report/hr_holidays_employee_counter.py b/hr_holidays_usability/report/hr_holidays_employee_counter.py index be8c227..1680ae4 100644 --- a/hr_holidays_usability/report/hr_holidays_employee_counter.py +++ b/hr_holidays_usability/report/hr_holidays_employee_counter.py @@ -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 -# -# 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 . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015-2017 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# 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, diff --git a/hr_holidays_usability/report/hr_holidays_employee_counter_view.xml b/hr_holidays_usability/report/hr_holidays_employee_counter_view.xml index 84ab852..9118fba 100644 --- a/hr_holidays_usability/report/hr_holidays_employee_counter_view.xml +++ b/hr_holidays_usability/report/hr_holidays_employee_counter_view.xml @@ -1,6 +1,5 @@ - - + hr.holidays.employee.counter.tree @@ -44,8 +43,7 @@ + parent="hr_holidays.menu_hr_holidays_my_leaves"/> - - + diff --git a/hr_holidays_usability/res_config_view.xml b/hr_holidays_usability/res_config_view.xml deleted file mode 100644 index 68f6ec1..0000000 --- a/hr_holidays_usability/res_config_view.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - hr_holidays_usability.res.company.form - res.company - - - - - - - - - - - - diff --git a/hr_holidays_usability/security/holiday_security.xml b/hr_holidays_usability/security/holiday_security.xml index def8fb8..96c5f39 100644 --- a/hr_holidays_usability/security/holiday_security.xml +++ b/hr_holidays_usability/security/holiday_security.xml @@ -1,6 +1,5 @@ - - + @@ -38,8 +37,7 @@ Manager = person that administrates the holidays process : can see everything, d HR Manager can see all Holidays [(1,'=',1)] - + - - + diff --git a/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py index 8f83e28..94d1039 100644 --- a/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py +++ b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py @@ -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 -# -# 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 . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015-2017 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# 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') diff --git a/hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml b/hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml index 2ffa5b5..fdbc29a 100644 --- a/hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml +++ b/hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml @@ -1,12 +1,11 @@ - - + hr_holidays_mass_allocation_form @@ -38,8 +37,7 @@ + parent="hr_holidays_administration_menu" + groups="hr_holidays.group_hr_holidays_manager"/> - - + diff --git a/hr_holidays_usability/wizard/hr_holidays_post.py b/hr_holidays_usability/wizard/hr_holidays_post.py index 68e681d..b178152 100644 --- a/hr_holidays_usability/wizard/hr_holidays_post.py +++ b/hr_holidays_usability/wizard/hr_holidays_post.py @@ -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 -# -# 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 . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2015-2017 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# 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 diff --git a/hr_holidays_usability/wizard/hr_holidays_post_view.xml b/hr_holidays_usability/wizard/hr_holidays_post_view.xml index 75cfd36..eb17f6e 100644 --- a/hr_holidays_usability/wizard/hr_holidays_post_view.xml +++ b/hr_holidays_usability/wizard/hr_holidays_post_view.xml @@ -1,18 +1,17 @@ - - + hr_holidays_post_form hr.holidays.post -
+ @@ -40,8 +39,7 @@ + parent="hr_holidays_administration_menu" + groups="hr_holidays.group_hr_holidays_manager"/> - - + diff --git a/purchase_usability/__init__.py b/purchase_usability/__init__.py index 14a3e7a..62f29c5 100644 --- a/purchase_usability/__init__.py +++ b/purchase_usability/__init__.py @@ -2,3 +2,4 @@ from . import purchase from . import product +from . import partner diff --git a/purchase_usability/partner.py b/purchase_usability/partner.py new file mode 100644 index 0000000..7e1abde --- /dev/null +++ b/purchase_usability/partner.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# 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 diff --git a/purchase_usability/product.py b/purchase_usability/product.py index 8a297a6..009b8cf 100644 --- a/purchase_usability/product.py +++ b/purchase_usability/product.py @@ -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') diff --git a/purchase_usability/purchase.py b/purchase_usability/purchase.py index a7bb59f..c6489bc 100644 --- a/purchase_usability/purchase.py +++ b/purchase_usability/purchase.py @@ -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 diff --git a/sale_usability/__init__.py b/sale_usability/__init__.py index 2d93c6e..fa8603d 100644 --- a/sale_usability/__init__.py +++ b/sale_usability/__init__.py @@ -2,3 +2,4 @@ from . import sale from . import product +from . import partner diff --git a/sale_usability/partner.py b/sale_usability/partner.py new file mode 100644 index 0000000..07535ff --- /dev/null +++ b/sale_usability/partner.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# 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') diff --git a/sale_usability/product.py b/sale_usability/product.py index 1a02555..2bfc3b8 100644 --- a/sale_usability/product.py +++ b/sale_usability/product.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2016 Akretion (Alexis de Lattre ) +# © 2017 Akretion (Alexis de Lattre ) # 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') diff --git a/stock_usability/__init__.py b/stock_usability/__init__.py index 70f4030..9781d47 100644 --- a/stock_usability/__init__.py +++ b/stock_usability/__init__.py @@ -3,3 +3,4 @@ from . import stock from . import procurement from . import product +from . import partner diff --git a/stock_usability/partner.py b/stock_usability/partner.py new file mode 100644 index 0000000..a7e8c12 --- /dev/null +++ b/stock_usability/partner.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# © 2017 Akretion (Alexis de Lattre ) +# 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')