training cost should be bigger than zero

This commit is contained in:
Esraa-Exp 2025-02-18 10:36:40 +02:00
parent 2d714c0d0e
commit 83e36b36d7
2 changed files with 36 additions and 25 deletions

View File

@ -54,3 +54,9 @@ msgstr ""
#, python-format #, python-format
msgid "You must Enter Purchase Product in Training Type Configuration" msgid "You must Enter Purchase Product in Training Type Configuration"
msgstr "يجب ادخال منتج طلب الشراء في إعداد نوع المهام" 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 "تكلفة مركز التدريب يجب ان تكون اكبر من صفر"

View File

@ -17,35 +17,40 @@ class HrOfficialMission(models.Model):
# check if there is dealing with financial # check if there is dealing with financial
if self.mission_type.work_state == 'training': 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: if not self.mission_type.pr_product_id.id:
raise ValidationError(_("You must Enter Purchase Product in Training Type Configuration")) raise ValidationError(_("You must Enter Purchase Product in Training Type Configuration"))
product_line = { product_line = {
'product_id': self.mission_type.pr_product_id.id, 'product_id': self.mission_type.pr_product_id.id,
'qty': 1, 'qty': 1,
'expected_price': self.Training_cost, 'expected_price': self.Training_cost,
} }
purchase_request = self.env['purchase.request'].create({ purchase_request = self.env['purchase.request'].create({
'state': 'draft', 'state': 'draft',
'department_id': self.department_id2.id, 'department_id': self.department_id2.id,
'date': date.today(), 'date': date.today(),
'employee_id': self.employee_id.id, 'employee_id': self.employee_id.id,
'partner_id': self.partner_id.id, 'partner_id': self.partner_id.id,
'product_category_ids':[(4, self.mission_type.pr_product_id.categ_id.id)] , 'product_category_ids': [(4, self.mission_type.pr_product_id.categ_id.id)],
'purchase_purpose': self.training_details, 'purchase_purpose': self.training_details,
'line_ids': [(0, 0, product_line)] '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: else:
res = super(HrOfficialMission, self).approve() res = super(HrOfficialMission, self).approve()
return res return res