Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
4096 Visualizzazioni


def get_inputs(self, contract_ids, date_from, date_to):
"""This Compute the other inputs to employee payslip.
"""
res = super(SalaryRuleInput, self).get_inputs(contract_ids, date_from, date_to)
contract_obj = self.env['hr.contract']
emp_id = contract_obj.browse(contract_ids[0].id).employee_id
adv_salary = self.env['salary.advance'].search([('employee_id', '=', emp_id.id)])
for adv_obj in adv_salary:
current_date = datetime.strptime(date_from, '%Y-%m-%d').date().month
date = adv_obj.date
existing_date = datetime.strptime(date, '%Y-%m-%d').date().month
if current_date == existing_date:
state = adv_obj.state
amount = adv_obj.advance
for result in res:
if state == 'approve' and amount != 0 and result.get('code') == 'SAR':
result['amount'] = amount
return res
In this method odoo 12 gives me an error in the line 

current_date = datetime.strptime(date_from, '%Y-%m-%d').date().month
It said that first argument must be a string. Can you tell me how to fix it and why it is working in version 11?
Thanks in advance


Avatar
Abbandona

Grettings Abdullah, in this function get_inputs(self, contract_ids, date_from, date_to):
return me only one value of advance salary, but i want this return the sum of two values or more values of advance salary in the same month(was made the change to let me make more than one advance salary). Please, can you help me, wich will be the modification of the funcion code?

Risposta migliore

Hi,

In Odoo version 12, accessing a fields.Date or fields.Datetime value will no longer return a string with the representation of the date but a native python date(time) object. So you have to update the code accordingly here in Odoo12.

See: Framework change on Date and Datetime fields for v12

Thanks

Avatar
Abbandona
Autore

Thanks for replying sir! I am trying to understand whats written in the link but just to be sure can you tell me what necessary change will be made in the line below

current_date = datetime.strptime(date_from, '%Y-%m-%d').date().month

Post correlati Risposte Visualizzazioni Attività
6
mag 24
50664
1
feb 23
697
0
feb 23
724
0
nov 21
3200
3
set 21
12210