From 78157a7d7284ee1805c15dc7cf3b17fe3183885f Mon Sep 17 00:00:00 2001 From: kpo Date: Wed, 14 Nov 2018 12:20:58 +0700 Subject: [PATCH 01/20] [FIX] fix to be able to sync success --- Modules/Weladee_Attendances/__manifest__.py | 40 +----- .../models/sync/weladee_holiday.py | 4 +- .../models/weladee_attendance_sync.py | 5 +- .../models/weladee_holidays.py | 25 +--- .../models/weladee_settings.py | 2 +- .../security/ir.model.access.csv | 2 +- .../views/weladee_attendance.xml | 16 +-- .../views/weladee_attendance_settings.xml | 4 +- .../views/weladee_holiday.xml | 136 ++---------------- README.md | 6 +- 10 files changed, 38 insertions(+), 202 deletions(-) diff --git a/Modules/Weladee_Attendances/__manifest__.py b/Modules/Weladee_Attendances/__manifest__.py index 9bff428..063acdc 100644 --- a/Modules/Weladee_Attendances/__manifest__.py +++ b/Modules/Weladee_Attendances/__manifest__.py @@ -1,26 +1,7 @@ -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-Now Tiny SPRL (). All Rights Reserved -# d$ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- { "name" : "Weladee attendances module", -"version" : "4.05", +"version" : "5.00", "author" : "Frontware International", "category" : "Generic Modules", 'summary': 'Weladee-Odoo attendances\'s module', @@ -40,7 +21,7 @@ "views/fw_hr_employee.xml"], "installable" : True, "active" : False, -"website" : "https://www.weladee.com/", +"website" : "https://github.com/Frontware/Weladee-odoo", "description":""" Weladee attendances module ========================== @@ -50,23 +31,10 @@ change log: ------------------------------------ -* 2018-06-12 KPO fixed sync -* 2017-07-18 CKA add view synchronous menu For sync Employee, Department, Holiday and attences on Attendances menu -* 2018-05-15 CKA change code for support odoo 11 -* 2018-05-16 CKA add event sync odoo to weladee -* 2018-05-17 CKA Sync employee for update on odoo datas, check duplicate check in -* 2018-05-18 CKA add button to open weladee employee -* 2018-05-21 CKA add new event when syn and fix problem when update employee -* 2018-05-22 CKA fixed problem when sync position on odoo to weladee -* 2018-05-23 CKA changed code for sync odoo to weladee -* 2018-05-24 CKA fixed problem when sync, add new fields on employee -* 2018-05-25 CKA add new fields for sync +* 2018-11-14 KPO compatible with odoo12 requirement: ------------------------------------ -* grpcio - - pip3 install grpcio * grpc diff --git a/Modules/Weladee_Attendances/models/sync/weladee_holiday.py b/Modules/Weladee_Attendances/models/sync/weladee_holiday.py index 8ccaa14..6e11519 100644 --- a/Modules/Weladee_Attendances/models/sync/weladee_holiday.py +++ b/Modules/Weladee_Attendances/models/sync/weladee_holiday.py @@ -105,7 +105,7 @@ def _update_weladee_holiday_back(weladee_holiday, holiday_odoo, context_sync, st def sync_holiday(self, emp_obj, holiday_obj, com_holiday_obj, authorization, context_sync, odoo_weladee_ids, holiday_status_id, to_email): ''' sync all holiday from weladee (1 way from weladee) - + 2018-11-14 KPO change hr.holidays to hr.leave ''' context_sync['stat-hol'] = {'to-sync':0, "create":0, "update": 0, "error":0} odoo_hol = False @@ -177,7 +177,7 @@ def sync_holiday(self, emp_obj, holiday_obj, com_holiday_obj, authorization, con template = self.env.ref('Weladee_Attendances.weladee_attendance_allocate_emp_mail', raise_if_not_found=False) if template: - allocation_url='%s/web#view_type=list&model=hr.holidays&menu_id=%s&action=%s' % ( + allocation_url='%s/web#view_type=list&model=hr.leave&menu_id=%s&action=%s' % ( self.env['ir.config_parameter'].search([('key','=','web.base.url')]).value, self.env.ref('hr_holidays.menu_open_department_leave_allocation_approve').id, self.env.ref('hr_holidays.open_department_holidays_allocation_approve').id) diff --git a/Modules/Weladee_Attendances/models/weladee_attendance_sync.py b/Modules/Weladee_Attendances/models/weladee_attendance_sync.py index d91dc33..e7b81e3 100644 --- a/Modules/Weladee_Attendances/models/weladee_attendance_sync.py +++ b/Modules/Weladee_Attendances/models/weladee_attendance_sync.py @@ -41,6 +41,9 @@ def start_sync(self): request-logs-key: internal use for prevent write duplicate log request-email : email recipient request-debug : display debug log + + remarks: + 2018-11-14 KPO change hr.holidays to hr.leave ''' elapse_start = datetime.today() user_tz = pytz.timezone(self.env.context.get('tz') or self.env.user.tz or 'UTC') @@ -111,7 +114,7 @@ def start_sync(self): if not sync_has_error(context_sync): sync_logdebug(context_sync,"Start sync...Holiday") - hr_obj = self.env['hr.holidays'] + hr_obj = self.env['hr.leave'] com_hr_obj = self.env['weladee_attendance.company.holidays'] sync_holiday(self, emp_obj, hr_obj, com_hr_obj, authorization, context_sync, odoo_weladee_ids, holiday_status_id, to_email) diff --git a/Modules/Weladee_Attendances/models/weladee_holidays.py b/Modules/Weladee_Attendances/models/weladee_holidays.py index 248ea67..2c5730d 100644 --- a/Modules/Weladee_Attendances/models/weladee_holidays.py +++ b/Modules/Weladee_Attendances/models/weladee_holidays.py @@ -12,7 +12,7 @@ from odoo.addons.Weladee_Attendances.library.weladee_translation import allocate_holiday_tag class weladee_holidays(models.Model): - _inherit = 'hr.holidays' + _inherit = 'hr.leave' weladee_code = fields.Char('Weladee Code') weladee_sick = fields.Boolean('Sick') @@ -20,25 +20,4 @@ class weladee_holidays(models.Model): @api.multi def action_allocated(self): for each in self: - each.write({'state':'validate'}) - - @api.multi - def name_get(self): - res = super(weladee_holidays, self).name_get() - # fixed allocate by tag name - fixed_res = {} - for leave in self: - if leave.type != 'remove': - fixed_res[leave.id] = _("Allocation of %s : %.2f day(s) To %s") % \ - (leave.holiday_status_id.name, - leave.number_of_days_temp, - leave.employee_id.name if leave.employee_id else allocate_holiday_tag() % leave.category_id.name) - - newres = [] - for leave in res: - if leave[0] in fixed_res: - newres.append((leave[0],fixed_res[leave[0]])) - else: - newres.append(leave) - - return newres \ No newline at end of file + each.write({'state':'validate'}) \ No newline at end of file diff --git a/Modules/Weladee_Attendances/models/weladee_settings.py b/Modules/Weladee_Attendances/models/weladee_settings.py index 7c01f83..33f087c 100644 --- a/Modules/Weladee_Attendances/models/weladee_settings.py +++ b/Modules/Weladee_Attendances/models/weladee_settings.py @@ -142,7 +142,7 @@ def _get_holiday_notify_leave_req_email(self): return get_holiday_notify_email(self) - holiday_status_id = fields.Many2one("hr.holidays.status", String="Leave Type",required=True,default=_get_holiday_status ) + holiday_status_id = fields.Many2one("hr.leave.holiday_status_id", String="Leave Type",required=True,default=_get_holiday_status ) holiday_notify_leave_req = fields.Boolean('Notify if there is not enough allocated leave request', default=_get_holiday_notify_leave_req ) holiday_notify_leave_req_email = fields.Text('Notified Email', default=_get_holiday_notify_leave_req_email) diff --git a/Modules/Weladee_Attendances/security/ir.model.access.csv b/Modules/Weladee_Attendances/security/ir.model.access.csv index c46b41d..b91b7b0 100644 --- a/Modules/Weladee_Attendances/security/ir.model.access.csv +++ b/Modules/Weladee_Attendances/security/ir.model.access.csv @@ -1,2 +1,2 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -group_weladee_leave_allocation_all,group_weladee_leave_allocation_all,hr_holidays.model_hr_holidays,Weladee_Attendances.group_weladee_leave_allocation,1,1,1,1 \ No newline at end of file +group_weladee_leave_allocation_all,group_weladee_leave_allocation_all,hr_holidays.model_hr_leave,Weladee_Attendances.group_weladee_leave_allocation,1,1,1,1 \ No newline at end of file diff --git a/Modules/Weladee_Attendances/views/weladee_attendance.xml b/Modules/Weladee_Attendances/views/weladee_attendance.xml index 39a786d..ce40dc5 100644 --- a/Modules/Weladee_Attendances/views/weladee_attendance.xml +++ b/Modules/Weladee_Attendances/views/weladee_attendance.xml @@ -13,15 +13,15 @@ weladee_attendance_form
-