Skip to content

[18.0][IMP] payroll: extensible formula help; rule_time_parameter docs fix - #310

Open
nimarosa wants to merge 2 commits into
OCA:18.0from
nimarosa:18.0-imp-payroll-formula-help-docs
Open

nimarosa wants to merge 2 commits into
OCA:18.0from
nimarosa:18.0-imp-payroll-formula-help-docs

Conversation

@nimarosa

Copy link
Copy Markdown
Contributor
  • [FIX] payroll_rule_time_parameter: the README told users to call a
    payslip.time_parameter() method that does not exist; documents the real
    rule_parameter(code, date=False, get="value") helper and covers it with a test.
  • [IMP] payroll: the salary rule "Help" page duplicated _get_baselocaldict() by
    hand in static XML; _get_formula_help_sections() now generates it and lets other
    modules extend it with super().
  • payroll_rule_time_parameter and payroll_contract_advantages each add their own
    section through that extension point.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @appstogrow,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added mod:payroll Module payroll series:18.0 mod:payroll_contract_advantages Module payroll_contract_advantages mod:payroll_rule_time_parameter Module payroll_rule_time_parameter labels Sep 22, 2026
The README told salary rule authors to call `payslip.time_parameter("mycode")`,
a method that does not exist in this module nor anywhere else: the helper it
adds is `rule_parameter(code, date=False, get="value")`, which defaults the date
to the start date of the payslip. Document it with its arguments, and give the
module the summary it was missing.

The menu was named "Time Parameters" while the action it opens is named "Rule
Parameters", so the breadcrumb renamed itself on click; the menu now uses the
name of the action, which is also the name of the helper.

The test called `get_time_parameter` twice -- the inherited method from
`base_time_parameter` -- so `rule_parameter` itself, and the date defaulting
that is this module's whole point, were never run. They are covered now, along
with an explicit date and `get="date"`.
The "Help" page of the salary rule form listed, in static XML, the objects
a formula may use. That list duplicates `hr.payslip._get_baselocaldict()`
by hand, so it drifts from it silently, and it offers no extension point:
a module that injects its own object in the local dict -- through
`_get_baselocaldict()`, `get_payroll_dict()`, `get_current_contract_dict()`
or `_get_tools_dict()` -- had nowhere to document it, and the user writing
the formula had no way to discover it.

`hr.salary.rule._get_formula_help_sections()` now returns that content as
an ordered list of `(title, [(identifier, description), ...])`, rendered
by the computed `formula_help` field which the page shows instead of the
static lists. A module extends the method with `super()` and appends its
own section.

Everything is escaped on render, so a section is data, not markup, and a
translation cannot break the page.

Two modules extend it with their own object:

* `payroll_rule_time_parameter` documents `payslip.rule_parameter()`, the
  helper this module exists for, with its date argument and `get="date"`.
* `payroll_contract_advantages` documents `current_contract.advantages`,
  which it adds to the formula's local dict and which was written down
  nowhere before.
@nimarosa
nimarosa force-pushed the 18.0-imp-payroll-formula-help-docs branch from 75b8bee to 6822efc Compare September 22, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:payroll_contract_advantages Module payroll_contract_advantages mod:payroll_rule_time_parameter Module payroll_rule_time_parameter mod:payroll Module payroll series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants