diff --git a/hr_holidays_lunch_voucher/__init__.py b/hr_holidays_lunch_voucher/__init__.py new file mode 100644 index 0000000..1347170 --- /dev/null +++ b/hr_holidays_lunch_voucher/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + +from . import company +from . import hr_holidays +from . import hr_employee +from . import lunch_voucher_attribution +from . import wizard diff --git a/hr_holidays_lunch_voucher/__openerp__.py b/hr_holidays_lunch_voucher/__openerp__.py new file mode 100644 index 0000000..26eb855 --- /dev/null +++ b/hr_holidays_lunch_voucher/__openerp__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 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 Lunch Voucher', + 'version': '10.0.1.0.0', + 'category': 'Human Resources', + 'license': 'AGPL-3', + 'summary': 'Manage lunch vouchers in holidays requests', + 'description': '', + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['hr_holidays_usability', 'purchase'], + 'data': [ + 'security/ir.model.access.csv', + 'security/lunch_voucher_security.xml', + 'product_data.xml', + 'company_view.xml', + 'wizard/lunch_voucher_purchase_view.xml', + 'lunch_voucher_attribution_view.xml', + 'hr_employee_view.xml', + 'hr_holidays_view.xml', + 'wizard/hr_holidays_post_view.xml', + ], + 'installable': True, +} diff --git a/hr_holidays_lunch_voucher/company.py b/hr_holidays_lunch_voucher/company.py new file mode 100644 index 0000000..8ac3977 --- /dev/null +++ b/hr_holidays_lunch_voucher/company.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 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 +import openerp.addons.decimal_precision as dp + + +class ResCompany(models.Model): + _inherit = 'res.company' + + lunch_voucher_product_id = fields.Many2one( + 'product.product', string='Lunch Voucher Product', + ondelete='restrict') + lunch_voucher_employer_price = fields.Float( + 'Lunch Voucher Employer Price', digits=dp.get_precision('Account')) + + # Add constrain to check that lunch_voucher_employer_price is between + # 50% and 60% of the price of lunch_voucher_product_id for France diff --git a/hr_holidays_lunch_voucher/company_view.xml b/hr_holidays_lunch_voucher/company_view.xml new file mode 100644 index 0000000..aa2c37e --- /dev/null +++ b/hr_holidays_lunch_voucher/company_view.xml @@ -0,0 +1,29 @@ + + + + + + + + + lunch_voucher.company.form + res.company + + + + + + + + + + + + + + + diff --git a/hr_holidays_lunch_voucher/hr_employee.py b/hr_holidays_lunch_voucher/hr_employee.py new file mode 100644 index 0000000..20363a5 --- /dev/null +++ b/hr_holidays_lunch_voucher/hr_employee.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# © 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 + + +class HrEmployee(models.Model): + _inherit = 'hr.employee' + + lunch_voucher = fields.Boolean(string="Has Lunch Vouchers", default=True) diff --git a/hr_holidays_lunch_voucher/hr_employee_view.xml b/hr_holidays_lunch_voucher/hr_employee_view.xml new file mode 100644 index 0000000..1a6ed22 --- /dev/null +++ b/hr_holidays_lunch_voucher/hr_employee_view.xml @@ -0,0 +1,25 @@ + + + + + + + + + lunch_voucher.hr.employee.form + hr.employee + + + + + + + + + + + diff --git a/hr_holidays_lunch_voucher/hr_holidays.py b/hr_holidays_lunch_voucher/hr_holidays.py new file mode 100644 index 0000000..cb16756 --- /dev/null +++ b/hr_holidays_lunch_voucher/hr_holidays.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# © 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 dateutil.relativedelta import relativedelta + + +class HrHolidays(models.Model): + _inherit = 'hr.holidays' + + lunch_voucher_id = fields.Many2one( + 'lunch.voucher.attribution', + string="Related Lunch Voucher Attribution") + lunch_voucher_remove_qty = fields.Integer( + compute='_compute_lunch_voucher_remove_qty', readonly=True, + store=True, string='Lunch Vouchers to Deduct') + + @api.depends('employee_id', 'vacation_date_from', 'vacation_date_to') + @api.multi + def _compute_lunch_voucher_remove_qty(self): + hhpo = self.env['hr.holidays.public'] + for hol in self: + qty = 0 + if ( + hol.type == 'remove' and + hol.vacation_date_from and + hol.vacation_date_to): + start_date_dt = fields.Date.from_string(hol.vacation_date_from) + end_date_str = hol.vacation_date_to + date_dt = start_date_dt + # Remove 1 full LV when vacation_time_from == noon + # and also when vacation_time_to == noon + while True: + if ( + date_dt.weekday() not in (5, 6) and + not hhpo.is_public_holiday( + date_dt, hol.employee_id.id)): + qty += 1 + date_dt += relativedelta(days=1) + date_str = fields.Date.to_string(date_dt) + if date_str > end_date_str: + break + hol.lunch_voucher_remove_qty = qty diff --git a/hr_holidays_lunch_voucher/hr_holidays_view.xml b/hr_holidays_lunch_voucher/hr_holidays_view.xml new file mode 100644 index 0000000..52bffe8 --- /dev/null +++ b/hr_holidays_lunch_voucher/hr_holidays_view.xml @@ -0,0 +1,39 @@ + + + + + + + + + hr_holidays_lunch_voucher.leave_request_form + hr.holidays + + + + + + + + + + + + + hr_holidays_lunch_voucher.leave_request_tree + hr.holidays + + + + + + + + + + + diff --git a/hr_holidays_lunch_voucher/lunch_voucher_attribution.py b/hr_holidays_lunch_voucher/lunch_voucher_attribution.py new file mode 100644 index 0000000..a3451e2 --- /dev/null +++ b/hr_holidays_lunch_voucher/lunch_voucher_attribution.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# © 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 + + +class LunchVoucherAttribution(models.Model): + _name = 'lunch.voucher.attribution' + _description = 'Lunch Voucher Attribution' + _order = 'date desc' + + employee_id = fields.Many2one( + 'hr.employee', string='Employee', ondelete='restrict', + required=True, readonly=True) + company_id = fields.Many2one( + related='employee_id.resource_id.company_id', readonly=True, + store=True) + date = fields.Date('Attribution Date', readonly=True) + purchase_id = fields.Many2one( + 'purchase.order', 'Purchase Order', + readonly=True) + month_work_days = fields.Integer( + 'Month Work Days', + help="Number of work days of the month (without taking into " + "account the holidays)") + no_lunch_days = fields.Integer( + compute='_compute_qty', string='No Lunch Days', + readonly=True, store=True) + qty = fields.Integer( + compute='_compute_qty', readonly=True, store=True, + string='Lunch Voucher Quantity') + holiday_ids = fields.One2many( + 'hr.holidays', 'lunch_voucher_id', readonly=True) + + @api.depends('month_work_days', 'holiday_ids.lunch_voucher_remove_qty') + @api.multi + def _compute_qty(self): + for rec in self: + no_lunch_days = 0 + for hol in rec.holiday_ids: + no_lunch_days += hol.lunch_voucher_remove_qty + rec.no_lunch_days = no_lunch_days + rec.qty = rec.month_work_days - no_lunch_days diff --git a/hr_holidays_lunch_voucher/lunch_voucher_attribution_view.xml b/hr_holidays_lunch_voucher/lunch_voucher_attribution_view.xml new file mode 100644 index 0000000..12516ef --- /dev/null +++ b/hr_holidays_lunch_voucher/lunch_voucher_attribution_view.xml @@ -0,0 +1,97 @@ + + + + + + + + + lunch.voucher.attribution.form + lunch.voucher.attribution + +
+ + + + + + + + + + + + +
+
+
+ + + lunch.voucher.attribution.tree + lunch.voucher.attribution + + + + + + + + + + + + + + + lunch.voucher.attribution.search + lunch.voucher.attribution + + + + + + + + + + + + + + + + lunch.voucher.attribution.graph + lunch.voucher.attribution + + + + + + + + + + Lunch Voucher Attribution + lunch.voucher.attribution + tree,form,graph + + + + + + +
+
diff --git a/hr_holidays_lunch_voucher/product_data.xml b/hr_holidays_lunch_voucher/product_data.xml new file mode 100644 index 0000000..47749c6 --- /dev/null +++ b/hr_holidays_lunch_voucher/product_data.xml @@ -0,0 +1,27 @@ + + + + + + + + Lunch Vouchers + + + + 0 + 8 + service + + + + + + + + + + + + + diff --git a/hr_holidays_lunch_voucher/security/ir.model.access.csv b/hr_holidays_lunch_voucher/security/ir.model.access.csv new file mode 100644 index 0000000..bbab688 --- /dev/null +++ b/hr_holidays_lunch_voucher/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_lunch_voucher_attribution_full,Full access on lunch_voucher_attribution,model_lunch_voucher_attribution,base.group_hr_manager,1,1,1,1 +access_lunch_voucher_attribution_read,Read access on lunch_voucher_attribution,model_lunch_voucher_attribution,base.group_user,1,0,0,0 diff --git a/hr_holidays_lunch_voucher/security/lunch_voucher_security.xml b/hr_holidays_lunch_voucher/security/lunch_voucher_security.xml new file mode 100644 index 0000000..fa6acfa --- /dev/null +++ b/hr_holidays_lunch_voucher/security/lunch_voucher_security.xml @@ -0,0 +1,28 @@ + + + + + + + Personal Lunch Voucher Attributions + + [('employee_id.user_id', '=', user.id)] + + + + + HR Officer sees all Lunch Voucher Attributions + + [(1, '=', 1)] + + + + + Lunch Voucher Attribution multi-company + + ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + + + + diff --git a/hr_holidays_lunch_voucher/wizard/__init__.py b/hr_holidays_lunch_voucher/wizard/__init__.py new file mode 100644 index 0000000..7791d6a --- /dev/null +++ b/hr_holidays_lunch_voucher/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- encoding: utf-8 -*- + +from . import hr_holidays_post +from . import lunch_voucher_purchase diff --git a/hr_holidays_lunch_voucher/wizard/hr_holidays_post.py b/hr_holidays_lunch_voucher/wizard/hr_holidays_post.py new file mode 100644 index 0000000..9967486 --- /dev/null +++ b/hr_holidays_lunch_voucher/wizard/hr_holidays_post.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# © 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 dateutil.relativedelta import relativedelta +import logging + +logger = logging.getLogger(__name__) + + +class HrHolidaysPost(models.TransientModel): + _inherit = 'hr.holidays.post' + + lunch_voucher_po = fields.Boolean( + string='Generate Lunch Voucher Purchase Order') + work_days = fields.Integer(string='Work Days') + + @api.model + def default_get(self, fields_list): + res = super(HrHolidaysPost, self).default_get(fields_list) + hhpo = self.env['hr.holidays.public'] + company = self.env.user.company_id + if company.lunch_voucher_product_id: + res['lunch_voucher_po'] = True + today = fields.Date.context_today(self) + today_dt = fields.Date.from_string(today) + cur_month = today_dt.month + # last day of month + date_dt = today_dt + relativedelta(day=31) + work_days = date_dt.day + logger.info('Number of days in the month: %d', work_days) + # from last day of month to the first + while date_dt.month == cur_month: + if hhpo.is_public_holiday(date_dt): + work_days -= 1 + logger.info( + "%s is a bank holiday, don't count", date_dt) + # if it's a saturday/sunday + elif date_dt.weekday() in (5, 6): + work_days -= 1 + logger.info( + "%s is a saturday/sunday, don't count", date_dt) + date_dt += relativedelta(days=-1) + logger.info('Number of work days in the month: %d', work_days) + res['work_days'] = work_days + return res + + @api.multi + def run(self): + self.ensure_one() + lvao = self.env['lunch.voucher.attribution'] + today = fields.Date.context_today(self) + employees = self.env['hr.employee'].search([ + ('lunch_voucher', '=', True), + ('company_id', '=', self.env.user.company_id.id), + ]) + lv_dict = {} + for employee in employees: + lv_dict[employee.id] = [] + for hol in self.holidays_to_post_ids: + if not hol.lunch_voucher_id and hol.employee_id.id in lv_dict: + lv_dict[hol.employee_id.id].append(hol.id) + for employee_id, hol_ids in lv_dict.iteritems(): + vals = { + 'employee_id': employee_id, + 'date': today, + 'month_work_days': self.work_days, + } + if hol_ids: + vals['holiday_ids'] = [(6, 0, hol_ids)] + lvao.create(vals) + return super(HrHolidaysPost, self).run() diff --git a/hr_holidays_lunch_voucher/wizard/hr_holidays_post_view.xml b/hr_holidays_lunch_voucher/wizard/hr_holidays_post_view.xml new file mode 100644 index 0000000..2933eb5 --- /dev/null +++ b/hr_holidays_lunch_voucher/wizard/hr_holidays_post_view.xml @@ -0,0 +1,27 @@ + + + + + + + + + hr_holidays_post_form + hr.holidays.post + + + + + + + + + + + + diff --git a/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase.py b/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase.py new file mode 100644 index 0000000..bd7f24e --- /dev/null +++ b/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +# © 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, api, _ +from openerp.exceptions import Warning as UserError + + +class LunchVoucherPurchase(models.TransientModel): + _name = 'lunch.voucher.purchase' + _description = 'Purchase Lunch Vouchers Wizard' + + @api.multi + def run(self): + self.ensure_one() + company = self.env.user.company_id + if not company.lunch_voucher_product_id: + raise UserError(_( + "Lunch Voucher Product not configured on company %s") + % company.name) + if not company.lunch_voucher_product_id.seller_id: + raise UserError(_( + "Missing supplier on Product '%s'.") + % company.lunch_voucher_product_id.name) + + poo = self.env['purchase.order'] + polo = self.env['purchase.order.line'] + lvao = self.env['lunch.voucher.attribution'] + assert self._context.get('active_model') ==\ + 'lunch.voucher.attribution', 'wrong source model' + assert self._context.get('active_ids'), 'missing active_ids in ctx' + lvouchers = lvao.browse(self._context['active_ids']) + total_qty = 0 + for lvoucher in lvouchers: + if lvoucher.purchase_id: + raise UserError(_( + "One of the Lunch Voucher Attributions you selected " + "related to employee '%s' is already linked to a " + "purchase order.") % lvoucher.employee_id.name) + if lvoucher.qty < 0: + raise UserError(_( + "One of the Lunch Voucher Attributions you selected " + "related to employee '%s' has a negative quantity.") + % lvoucher.employee_id.name) + total_qty += lvoucher.qty + + supplier = company.lunch_voucher_product_id.seller_id + pick_type_id = poo.default_get(['picking_type_id'])['picking_type_id'] + onchange_ptype_vals = poo.browse(False).onchange_picking_type_id( + pick_type_id) + vals = onchange_ptype_vals['value'] + onchange_vals = poo.browse(False).onchange_partner_id(supplier.id) + vals.update(onchange_vals['value']) + vals['partner_id'] = supplier.id + + product = company.lunch_voucher_product_id + onchange_product_vals = polo.browse(False).onchange_product_id( + vals.get('pricelist_id'), product.id, total_qty, False, + supplier.id, fiscal_position_id=vals.get('fiscal_position_id')) + lvals = onchange_product_vals['value'] + lvals['product_id'] = product.id + lvals['product_qty'] = total_qty + if lvals['taxes_id']: + lvals['taxes_id'] = [(6, 0, lvals['taxes_id'])] + vals['order_line'] = [(0, 0, lvals)] + po = poo.create(vals) + lvouchers.write({'purchase_id': po.id}) + + action = self.env['ir.actions.act_window'].for_xml_id( + 'purchase', 'purchase_rfq') + action.update({ + 'res_id': po.id, + 'view_mode': 'form,tree', + 'views': False, + }) + return action diff --git a/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase_view.xml b/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase_view.xml new file mode 100644 index 0000000..772a4fd --- /dev/null +++ b/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase_view.xml @@ -0,0 +1,36 @@ + + + + + + + + lunch_voucher_purchase_form + lunch.voucher.purchase + +
+ + +
+
+
+
+
+ + + Create PO for Lunch Vouchers + lunch.voucher.purchase + form + new + + +
+
diff --git a/hr_holidays_lunch_voucher_natixis/__init__.py b/hr_holidays_lunch_voucher_natixis/__init__.py new file mode 100644 index 0000000..ece3401 --- /dev/null +++ b/hr_holidays_lunch_voucher_natixis/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import company +from . import wizard diff --git a/hr_holidays_lunch_voucher_natixis/__openerp__.py b/hr_holidays_lunch_voucher_natixis/__openerp__.py new file mode 100644 index 0000000..c0e41cf --- /dev/null +++ b/hr_holidays_lunch_voucher_natixis/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 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 Lunch Voucher Natixis', + 'version': '10.0.1.0.0', + 'category': 'Human Resources', + 'license': 'AGPL-3', + 'summary': 'Generate order file for Natixis lunch vouchers', + 'description': '', + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['hr_holidays_lunch_voucher'], + 'data': [ + 'company_view.xml', + ], + 'installable': True, +} diff --git a/hr_holidays_lunch_voucher_natixis/company.py b/hr_holidays_lunch_voucher_natixis/company.py new file mode 100644 index 0000000..d68d8c7 --- /dev/null +++ b/hr_holidays_lunch_voucher_natixis/company.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 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 + + +class ResCompany(models.Model): + _inherit = 'res.company' + + lunch_voucher_natixis_customer_code = fields.Char( + string='Natixis Customer Ref', size=7) + lunch_voucher_natixis_delivery_code = fields.Char( + string='Natixis Delivery Code', size=7) diff --git a/hr_holidays_lunch_voucher_natixis/company_view.xml b/hr_holidays_lunch_voucher_natixis/company_view.xml new file mode 100644 index 0000000..8c1ded6 --- /dev/null +++ b/hr_holidays_lunch_voucher_natixis/company_view.xml @@ -0,0 +1,26 @@ + + + + + + + + + natixis.lunch_voucher.company.form + res.company + + + + + + + + + + + + diff --git a/hr_holidays_lunch_voucher_natixis/wizard/__init__.py b/hr_holidays_lunch_voucher_natixis/wizard/__init__.py new file mode 100644 index 0000000..fa75146 --- /dev/null +++ b/hr_holidays_lunch_voucher_natixis/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- encoding: utf-8 -*- + +from . import lunch_voucher_purchase diff --git a/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py b/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py new file mode 100644 index 0000000..09edb20 --- /dev/null +++ b/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +# © 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 as UserError + + +class LunchVoucherPurchase(models.TransientModel): + _inherit = 'lunch.voucher.purchase' + + @api.multi + def run(self): + self.ensure_one() + action = super(LunchVoucherPurchase, self).run() + company = self.env.user.company_id + lvao = self.env['lunch.voucher.attribution'] + assert self._context.get('active_model')\ + == 'lunch.voucher.attribution', 'wrong source model' + assert self._context.get('active_ids'), 'missing active_ids in ctx' + if not company.lunch_voucher_natixis_customer_code: + raise UserError(_( + "Missing Natixis Customer Ref on company '%s'.") + % company.name) + if not company.lunch_voucher_natixis_delivery_code: + raise UserError(_( + "Missing Natixis Delivery Code on company '%s'.") + % company.name) + if len(company.lunch_voucher_natixis_customer_code) != 7: + raise UserError(_( + "Natixis Customer Ref '%s' on company '%s' should " + "have 7 characters/digits.") + % (company.lunch_voucher_natixis_customer_code, company.name)) + if len(company.lunch_voucher_natixis_delivery_code) != 7: + raise UserError(_( + "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: + raise UserError(_( + "Lunch Voucher Employer Price not set on company '%s'.") + % company.name) + lvouchers = lvao.browse(self._context['active_ids']) + of = u'' + tmp = {} + for lvoucher in lvouchers: + if lvoucher.qty > 0: + if lvoucher.qty not in tmp: + tmp[lvoucher.qty] = 1 + else: + tmp[lvoucher.qty] += 1 + for vouchers_per_pack, pack_qty in tmp.iteritems(): + if vouchers_per_pack > 99: + raise UserError(_( + "Cannot order more than 99 vouchers per pack")) + line = u'%s%s%s%s%s%s%s%s\n' % ( + company.lunch_voucher_natixis_delivery_code, + company.lunch_voucher_natixis_customer_code, + unicode(pack_qty).zfill(3), + unicode(vouchers_per_pack).zfill(2), + unicode(pack_qty * vouchers_per_pack).zfill(5), + '{:05.2f}'.format( + company.lunch_voucher_product_id.standard_price), + '{:05.2f}'.format(company.lunch_voucher_employer_price), + ' ' * 64) + of += line + today_dt = fields.Date.from_string( + fields.Date.context_today(self)) + filename = 'E%s_%s.txt' % ( + company.lunch_voucher_natixis_customer_code, + today_dt.strftime('%d%m%Y')) + self.env['ir.attachment'].create({ + 'name': filename, + 'res_id': action['res_id'], + 'res_model': 'purchase.order', + 'datas': of.encode('base64'), + 'datas_fname': filename, + 'type': 'binary', + }) + return action diff --git a/hr_holidays_usability/hr_holidays.py b/hr_holidays_usability/hr_holidays.py index a3a0365..2f76910 100644 --- a/hr_holidays_usability/hr_holidays.py +++ b/hr_holidays_usability/hr_holidays.py @@ -241,6 +241,10 @@ class HrHolidays(models.Model): string='Public Title', help="Warning: this title is shown publicly in the " "calendar. Don't write private/personnal information in this field.") + # by default, there is no company_id field on hr.holidays ! + company_id = fields.Many2one( + related='employee_id.resource_id.company_id', store=True, + readonly=True) @api.one @api.constrains( diff --git a/hr_holidays_usability/hr_holidays_view.xml b/hr_holidays_usability/hr_holidays_view.xml index b105658..eae3361 100644 --- a/hr_holidays_usability/hr_holidays_view.xml +++ b/hr_holidays_usability/hr_holidays_view.xml @@ -61,6 +61,7 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> + @@ -90,6 +91,7 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> + diff --git a/hr_holidays_usability/security/holiday_security.xml b/hr_holidays_usability/security/holiday_security.xml index def8fb8..04d252e 100644 --- a/hr_holidays_usability/security/holiday_security.xml +++ b/hr_holidays_usability/security/holiday_security.xml @@ -1,6 +1,6 @@ - +