Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4105 Widoki


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


Awatar
Odrzuć

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?

Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
6
maj 24
50670
1
lut 23
697
0
lut 23
724
0
lis 21
3204
3
wrz 21
12213