diff --git a/odex25_hr/hr_training_payment/i18n/ar_001.po b/odex25_hr/hr_training_payment/i18n/ar_001.po index 536f3b25a..94757e257 100644 --- a/odex25_hr/hr_training_payment/i18n/ar_001.po +++ b/odex25_hr/hr_training_payment/i18n/ar_001.po @@ -54,3 +54,9 @@ msgstr "" #, python-format msgid "You must Enter Purchase Product in Training Type Configuration" msgstr "يجب ادخال منتج طلب الشراء في إعداد نوع المهام" + +#. module: hr_training_payment +#: code:addons/hr_training_payment/models/hr_official_mission.py:0 +#, python-format +msgid "Training Cost Must be Bigger than Zero" +msgstr "تكلفة مركز التدريب يجب ان تكون اكبر من صفر" diff --git a/odex25_hr/hr_training_payment/models/hr_official_mission.py b/odex25_hr/hr_training_payment/models/hr_official_mission.py index d0e964d76..39bad579d 100644 --- a/odex25_hr/hr_training_payment/models/hr_official_mission.py +++ b/odex25_hr/hr_training_payment/models/hr_official_mission.py @@ -17,35 +17,40 @@ class HrOfficialMission(models.Model): # check if there is dealing with financial if self.mission_type.work_state == 'training': - self.employee_ids.chick_not_overtime() + if self.Training_cost > 0.0: + self.employee_ids.chick_not_overtime() - if not self.mission_type.pr_product_id.id: - raise ValidationError(_("You must Enter Purchase Product in Training Type Configuration")) + if not self.mission_type.pr_product_id.id: + raise ValidationError(_("You must Enter Purchase Product in Training Type Configuration")) - product_line = { - 'product_id': self.mission_type.pr_product_id.id, - 'qty': 1, - 'expected_price': self.Training_cost, - } + product_line = { + 'product_id': self.mission_type.pr_product_id.id, + 'qty': 1, + 'expected_price': self.Training_cost, + } - purchase_request = self.env['purchase.request'].create({ - 'state': 'draft', - 'department_id': self.department_id2.id, - 'date': date.today(), - 'employee_id': self.employee_id.id, - 'partner_id': self.partner_id.id, - 'product_category_ids':[(4, self.mission_type.pr_product_id.categ_id.id)] , - 'purchase_purpose': self.training_details, - 'line_ids': [(0, 0, product_line)] - }) + purchase_request = self.env['purchase.request'].create({ + 'state': 'draft', + 'department_id': self.department_id2.id, + 'date': date.today(), + 'employee_id': self.employee_id.id, + 'partner_id': self.partner_id.id, + 'product_category_ids': [(4, self.mission_type.pr_product_id.categ_id.id)], + 'purchase_purpose': self.training_details, + 'line_ids': [(0, 0, product_line)] + }) + + self.purchase_request_id = purchase_request.id + self.state = "approve" + if self.mission_type.work_state and self.mission_type.duration_type == 'days': + for emp in self.employee_ids: + if emp.date_to >= fields.Date.today() >= emp.date_from: + emp.employee_id.write( + {'work_state': self.mission_type.work_state, 'active_mission_id': emp.id}) + self.call_cron_function() + else: + raise exceptions.Warning(_('Training Cost Must be Bigger than Zero')) - self.purchase_request_id = purchase_request.id - self.state = "approve" - if self.mission_type.work_state and self.mission_type.duration_type == 'days': - for emp in self.employee_ids: - if emp.date_to >= fields.Date.today() >= emp.date_from: - emp.employee_id.write({'work_state': self.mission_type.work_state, 'active_mission_id': emp.id}) - self.call_cron_function() else: res = super(HrOfficialMission, self).approve() return res