From 44b32672e2f6e02f77b0646e0ee7574baa942498 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 22 Sep 2017 15:57:16 +0200 Subject: [PATCH] 2 fixes in hr_holidays modules --- .../wizard/lunch_voucher_purchase.py | 13 ++++++++++++- hr_holidays_usability/wizard/hr_holidays_post.py | 8 +++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py b/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py index 09edb20..eab7495 100644 --- a/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py +++ b/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py @@ -5,6 +5,7 @@ from openerp import models, fields, api, _ from openerp.exceptions import Warning as UserError +from openerp.tools import float_is_zero class LunchVoucherPurchase(models.TransientModel): @@ -15,6 +16,8 @@ class LunchVoucherPurchase(models.TransientModel): self.ensure_one() action = super(LunchVoucherPurchase, self).run() company = self.env.user.company_id + # force_company to read standard_price properly + company = company.with_context(force_company=company.id) lvao = self.env['lunch.voucher.attribution'] assert self._context.get('active_model')\ == 'lunch.voucher.attribution', 'wrong source model' @@ -37,10 +40,18 @@ class LunchVoucherPurchase(models.TransientModel): "Natixis Delivery Code on company '%s' should " "have 7 characters/digits.") % (company.lunch_voucher_natixis_delivery_code, company.name)) - if not company.lunch_voucher_employer_price: + if float_is_zero( + company.lunch_voucher_employer_price, + precision_digits=2): raise UserError(_( "Lunch Voucher Employer Price not set on company '%s'.") % company.name) + if float_is_zero( + company.lunch_voucher_product_id.standard_price, + precision_digits=2): + raise UserError(_( + "Lunch Voucher Standard Price is not set on product '%s'.") + % company.lunch_voucher_product_id.display_name) lvouchers = lvao.browse(self._context['active_ids']) of = u'' tmp = {} diff --git a/hr_holidays_usability/wizard/hr_holidays_post.py b/hr_holidays_usability/wizard/hr_holidays_post.py index dbd4e28..bc329cd 100644 --- a/hr_holidays_usability/wizard/hr_holidays_post.py +++ b/hr_holidays_usability/wizard/hr_holidays_post.py @@ -74,9 +74,11 @@ class HrHolidaysPost(models.TransientModel): # because, after the write, it doesn't have a value any more !!! 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.')) + # Disable the raise below to make the module "hr_holidays_lunch_voucher" + # work even when nobody took holidays on the current month + # if not self.holidays_to_post_ids: + # raise Warning( + # _('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 action = {