Help

2

How to call a salary rule to calculate a specific field in python?

Avatar
Rihene

Hello everybody!!!!!!!

Please, i want to ask you i have a field in OpenERP.

And i want to know how can i call a salary rule that i have created to calculate a field that i will specify for my report.

Thanks a lot in advance.

Best Regards.


1 Comment
Avatar
Discard
Avatar
Kalpana Hemnani
-

Hello Drees, if you want to call a salary rule from a payslip, just go though get_payslip_lines() method, in that you can traverse salary rule. Hope this helps.

2 Answers
0
Avatar
Mohammed Assalateen
Best Answer

Hi

I am using odoo 12 enterprise. I added a field to the contract using studio (field name: x_studio_xxxx)

Then I created a salary rule , python code 

result=contract.x_studio_xxxx * 0.1

But that code won't run (error)

I think I am using a wrong way to access the new field, any Ideas please?


Avatar
Discard
0
Avatar
Kalpana Hemnani
Best Answer

Hello Drees,

You can use below variables in your salary rule:

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

These variables will work as a browse record for respective object.

For example,

if you want to access employee from payslip, you just have to define payslip.employee_id.

Hope this helps..!

Regards,

Kalpana Hemnani

1 Comment
Avatar
Discard
Avatar
Rihene
-

hi my friend :) thx a lot for your answer but what i want to know is how can i call a salary rule into a function and i will give it a specific field to work on its value plz