Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Payroll: How to reference a 'Salary Rule Parameter'

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
4496 Views
Avatar
Koos Kaspers

Since v15 its possible to create 'Salary Rule Parameters'. I'm trying to reference such a rule in a python code.

I'm aware of how to reference to, for example, an input parameter:



                    # 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'


So in order to reference an input variable, this is the syntax:

                    result = inputs.variable_name.amount * 0.10


But the documentation is not showing how to reference the newly introduced 'Salary Rule Parameter'. I already tried:

rule_parameter.variable_name.amount

and some other combinations of the word rule and parameter, but to no avail. Anybody knows how to reference it?

1
Avatar
Discard
Avatar
Rana Abdelsattar (abr)
Best Answer

In v17, you can reference a rule parameter using the code payslip._rule_parameter('parameter_code')

0
Avatar
Discard
Koos Kaspers
Author

are you sure to include the "_" before rule?

Rana Abdelsattar (abr)

In v16 it would be payslip.rule_parameter('code') but in 17 you need to include "_" before.

Which version are you using?

Koos Kaspers
Author

I'm on 17.0.

I just tried:

result = payslip._rule_parameter('abc')

And it's working as expected. Thank you so much!

Avatar
Renaud Desarzens
Best Answer

I was able to use a rule parameter in v16 like this:

result = payslip.rule_parameter('NameOfRuleParameter')

It returns the parameter value of it respecting the valid from date specified in the rule parameter.

0
Avatar
Discard
Sergey Vernyayev

argh. It gives me a nervous tick
- Error: <class 'AttributeError'>: "'hr.payslip' object has no attribute 'rule_parameter'" while evaluating

Koos Kaspers
Author

Hmm, same problem here:

Fout: <class 'AttributeError'>: "'hr.payslip' object has no attribute 'rule_parameter'" while evaluating

Are you really sure, the synax is payslip.rule_parameter('<code-of-rule-paramter?') ?

Waleed Ali Mohsen

You can use
payslip.rule_parameter('code_of_parameter').

The below is details from Odoo 15.0 commit.

In a salary rule, you can directly use `payslip.rule_parameter(code)`.
The version valid at the payslip end date is automatically chosen.

To retrieve a parameter value at a particular date,
use `self.env['hr.rule.parameter']._get_parameter_from_code(code, date)`.
The date is optional and set to today by default.

Koos Kaspers
Author

@Waleed, thanks for helping out. The first option you gave is already given by other people and is not working. I've tried the 2nd option you gave (retrieve a parameter value at a particular date) and this isn't working neither:

<class 'NameError'>: "name 'self' is not defined" while evaluating
"result = self.env['hr.rule.parameter']._get_parameter_from_code('abc', '2024-01-01')"

I'd say: please try it yourself. Create a "salary rule parameter" with code 'abc' and value '1'. Then create a "salary rule", choose 'python code' at 'amount type' and try to reference to the newly created salary rule parameter by entering:

result = payslip.rule_parameter('abc')

I'm pretty sure you will end up with the same error:

<class 'AttributeError'>: "'hr.payslip' object has no attribute 'rule_parameter'" while evaluating
"result = payslip.rule_parameter('abc')"

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now