跳至內容
選單
此問題已被標幟
1 回覆
4092 瀏覽次數


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


頭像
捨棄

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?

最佳答案

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

頭像
捨棄
作者

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

相關帖文 回覆 瀏覽次數 活動
6
5月 24
50663
1
2月 23
697
0
2月 23
724
0
11月 21
3196
3
9月 21
12208