浮动对象在 Odoo 15 中没有属性 'number_of_day error in payroll module'
float object has no attribute 'number_of_day error in payroll module' in Odoo 15
我在尝试从工资单中扣除无薪假时遇到错误 ValueError('<class \'AttributeError\'>: "\'float\' object has no attribute \'number_of_days\'" while evaluating\n\'result =-(contract.wage/31) * worked_days.Unpaid.number_of_days\'')
。我是 Odoo 的新手。请帮助我。
我最近安装了https://apps.odoo.com/apps/modules/15.0/om_hr_payroll/这个第三方社区版。
我已经创建了工资规则,如下面的快照
现在,然后我在薪资结构
中添加了薪资规则
现在,当我在员工工资单中单击计算 Sheet 时,出现如下快照
的错误
我看到了这个模块提供商公司的博客 post https://www.cybrosys.com/blog/hr-unpaid-leaves-payroll-management-in-odoo-10
但我的工资单仍然出错
My Odoo Version is latest odoo_15.0 (Community Edition)
Odoo 将遍历 Worked Days
行,使用它们的 code
将这些行添加到 worked_days_dict
worked_days_dict = {}
payslip = self.env['hr.payslip'].browse(payslip_id)
for worked_days_line in payslip.worked_days_line_ids:
worked_days_dict[worked_days_line.code] = worked_days_line
要使用以下表达式,您需要使用 Unpaid
代码添加工作日行:
result = (contract.wage/30) * worked_days.Unpaid.number_of_days
注意字段名称是:number_of_days
如果您正在使用此 https://apps.odoo.com/apps/modules/15.0/om_hr_payroll/ 薪资模块,则有许多对象变量可用于使用 python 代码部分自定义薪资规则。见下文我分享了可用变量列表
# Available variables:
#----------------------
# payslip: object containing the payslips
# employee: hr.employee object
# contract: hr.contract object
# rules: object containing the rules code (previously computed)
# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).
# worked_days: object containing the computed worked days.
# inputs: object containing the computed inputs.
# Note: returned value have to be set in the variable 'result'
wagePerDay = contract.wage // for get Wage from Contract
totalWorkingDays = worked_days.WORK100.number_of_days // for get total working days (excluded public holidays, Sunday also... if you set Saturday off then Saturdays also)
date2 = payslip.date_to // for get selected Payslip date_to
date1 = payslip.date_from // for get selected Payslip date_from
Leaves = 0
for line in payslip.worked_days_line_ids:
Leaves += line.number_of_days // get number of leave (category wise like, total unpaid leave, total of paid leaves, total of sick leaves, total of Global Leaves)
下面我分享了我对从工资中扣除无薪假的最终答复
这是Python条件字段输入
unpaidLeaves = 0
for line in payslip.worked_days_line_ids:
if line.name == "Unpaid" and line.code == "UNPAID" :
result = line.number_of_days
这是Python代码字段输入
# Available variables:
#----------------------
# payslip: object containing the payslips
# employee: hr.employee object
# contract: hr.contract object
# rules: object containing the rules code (previously computed)
# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).
# worked_days: object containing the computed worked days.
# inputs: object containing the computed inputs.
# Note: returned value have to be set in the variable 'result'
# ---------------------
# totalWorkingDays = worked_days.WORK100.number_of_days
# date2 = payslip.date_to
# date1 = payslip.date_from
# sec_Of_1Day = 86400
# wagePerHour = contract.wage / 30 / employee.resource_calendar_id.hours_per_day
wagePerDay = contract.wage / 30
unpaidLeaves = 0
if worked_days.Unpaid and worked_days.Unpaid.number_of_days or False:
result= wagePerDay * unpaidLeaves
else:
for line in payslip.worked_days_line_ids:
if line.name == "Unpaid" and line.code == "UNPAID" :
unpaidLeaves = line.number_of_days
result_qty = round(unpaidLeaves, 2)
result = round(wagePerDay, 2)
# result = wagePerDay
# result = wagePerDay * unpaidLeaves
见下面的输出快照
你可以在下面看到我的回答截图
-: python 条件:-
-: python 代码:-
除了建议的答案,
可以用这个公式在python中计算无薪休假金额:
wagePerDay = contract.wage / worked_days.WORK100.number_of_days
totalUnpaidWage = wagePerDay*worked_days.LEAVE90.number_of_days;
result = round(totalUnpaidWage, 2)
在哪里:
worked_days.WORK100.number_of_days 是 odoo 记录的那个月的总工作天数。
worked_days.LEAVE90.number_of_days是无薪假的次数。
代码 LEAVE90 可以在选项卡 未付工作条目类型 下配置,可以在编辑工资结构时找到。
从 Odoo 中找到示例图像
我在尝试从工资单中扣除无薪假时遇到错误 ValueError('<class \'AttributeError\'>: "\'float\' object has no attribute \'number_of_days\'" while evaluating\n\'result =-(contract.wage/31) * worked_days.Unpaid.number_of_days\'')
。我是 Odoo 的新手。请帮助我。
我最近安装了https://apps.odoo.com/apps/modules/15.0/om_hr_payroll/这个第三方社区版。
我已经创建了工资规则,如下面的快照
现在,然后我在薪资结构
中添加了薪资规则现在,当我在员工工资单中单击计算 Sheet 时,出现如下快照
的错误我看到了这个模块提供商公司的博客 post https://www.cybrosys.com/blog/hr-unpaid-leaves-payroll-management-in-odoo-10
但我的工资单仍然出错
My Odoo Version is latest odoo_15.0 (Community Edition)
Odoo 将遍历 Worked Days
行,使用它们的 code
worked_days_dict
worked_days_dict = {}
payslip = self.env['hr.payslip'].browse(payslip_id)
for worked_days_line in payslip.worked_days_line_ids:
worked_days_dict[worked_days_line.code] = worked_days_line
要使用以下表达式,您需要使用 Unpaid
代码添加工作日行:
result = (contract.wage/30) * worked_days.Unpaid.number_of_days
注意字段名称是:number_of_days
如果您正在使用此 https://apps.odoo.com/apps/modules/15.0/om_hr_payroll/ 薪资模块,则有许多对象变量可用于使用 python 代码部分自定义薪资规则。见下文我分享了可用变量列表
# Available variables:
#----------------------
# payslip: object containing the payslips
# employee: hr.employee object
# contract: hr.contract object
# rules: object containing the rules code (previously computed)
# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).
# worked_days: object containing the computed worked days.
# inputs: object containing the computed inputs.
# Note: returned value have to be set in the variable 'result'
wagePerDay = contract.wage // for get Wage from Contract
totalWorkingDays = worked_days.WORK100.number_of_days // for get total working days (excluded public holidays, Sunday also... if you set Saturday off then Saturdays also)
date2 = payslip.date_to // for get selected Payslip date_to
date1 = payslip.date_from // for get selected Payslip date_from
Leaves = 0
for line in payslip.worked_days_line_ids:
Leaves += line.number_of_days // get number of leave (category wise like, total unpaid leave, total of paid leaves, total of sick leaves, total of Global Leaves)
下面我分享了我对从工资中扣除无薪假的最终答复
这是Python条件字段输入
unpaidLeaves = 0
for line in payslip.worked_days_line_ids:
if line.name == "Unpaid" and line.code == "UNPAID" :
result = line.number_of_days
这是Python代码字段输入
# Available variables:
#----------------------
# payslip: object containing the payslips
# employee: hr.employee object
# contract: hr.contract object
# rules: object containing the rules code (previously computed)
# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).
# worked_days: object containing the computed worked days.
# inputs: object containing the computed inputs.
# Note: returned value have to be set in the variable 'result'
# ---------------------
# totalWorkingDays = worked_days.WORK100.number_of_days
# date2 = payslip.date_to
# date1 = payslip.date_from
# sec_Of_1Day = 86400
# wagePerHour = contract.wage / 30 / employee.resource_calendar_id.hours_per_day
wagePerDay = contract.wage / 30
unpaidLeaves = 0
if worked_days.Unpaid and worked_days.Unpaid.number_of_days or False:
result= wagePerDay * unpaidLeaves
else:
for line in payslip.worked_days_line_ids:
if line.name == "Unpaid" and line.code == "UNPAID" :
unpaidLeaves = line.number_of_days
result_qty = round(unpaidLeaves, 2)
result = round(wagePerDay, 2)
# result = wagePerDay
# result = wagePerDay * unpaidLeaves
见下面的输出快照
你可以在下面看到我的回答截图
-: python 条件:-
除了建议的答案, 可以用这个公式在python中计算无薪休假金额:
wagePerDay = contract.wage / worked_days.WORK100.number_of_days
totalUnpaidWage = wagePerDay*worked_days.LEAVE90.number_of_days;
result = round(totalUnpaidWage, 2)
在哪里: worked_days.WORK100.number_of_days 是 odoo 记录的那个月的总工作天数。
worked_days.LEAVE90.number_of_days是无薪假的次数。 代码 LEAVE90 可以在选项卡 未付工作条目类型 下配置,可以在编辑工资结构时找到。
从 Odoo 中找到示例图像