fix
This commit is contained in:
parent
350474daaf
commit
7d92fe3ea8
|
|
@ -252,7 +252,22 @@ class HrEmployee(models.Model):
|
|||
|
||||
@api.model
|
||||
def _default_emp_code(self):
|
||||
return "1"
|
||||
seq = self.env['ir.sequence'].next_by_code('hr.employee') or '/'
|
||||
emp_seq = self.env['hr.employee'].search([('active', 'in', [False, True])])
|
||||
|
||||
numbers = []
|
||||
for emp in emp_seq:
|
||||
if emp.emp_no and emp.emp_no.isdigit():
|
||||
numbers.append(int(emp.emp_no))
|
||||
|
||||
max_number = max(numbers) if numbers else 0
|
||||
|
||||
if seq.isdigit() and int(seq) != (max_number + 1):
|
||||
currnt_sequence = self.env['ir.sequence'].search([('code', '=', 'hr.employee')], limit=1)
|
||||
currnt_sequence.write({'number_next_actual': max_number + 1})
|
||||
seq = self.env['ir.sequence'].next_by_code('hr.employee') or '/'
|
||||
|
||||
return str(seq)
|
||||
|
||||
@api.depends('new_gosi')
|
||||
def _compute_gosi_years(self):
|
||||
|
|
@ -262,18 +277,17 @@ class HrEmployee(models.Model):
|
|||
|
||||
if emp.new_gosi and gosi_date:
|
||||
try:
|
||||
# gosi_active_date أصلاً Date field في Odoo، مش محتاج strptime
|
||||
if isinstance(gosi_date, str):
|
||||
date_activation = datetime.strptime(gosi_date, '%Y-%m-%d').date()
|
||||
else:
|
||||
date_activation = gosi_date # لو هو date object
|
||||
date_activation = gosi_date
|
||||
|
||||
today = date.today()
|
||||
years = today.year - date_activation.year - (
|
||||
(today.month, today.day) < (date_activation.month, date_activation.day)
|
||||
)
|
||||
except Exception:
|
||||
years = 0
|
||||
years = 0
|
||||
|
||||
emp.gosi_years = years
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue