Skip to content

[19.0][FIX] payroll: reject conflicting effective parameter values - #54

Open
votrelec wants to merge 3 commits into
Data-Dance:19.0from
votrelec:fix/sk-rule-parameter-effective-date-20261117
Open

votrelec wants to merge 3 commits into
Data-Dance:19.0from
votrelec:fix/sk-rule-parameter-effective-date-20261117

Conversation

@votrelec

Copy link
Copy Markdown
Contributor

The OCA parameter reader currently accepts conflicting definitions at the same effective date. A native copy of a value 1 to value 2 with the same date leaves calculation dependent on SQL tie order.

Select the latest effective date deterministically and check its evaluated definitions. Matching legacy rows remain readable; conflicting values raise a translated error. Earlier conflicts do not block a later unambiguous definition. The reader does not rewrite parameters or retained payroll. No uniqueness constraint or historical-data migration is added.

Validation: 18 targeted native Odoo 19 tests passed, including native copy, nested values, date boundaries, ordinary payroll read-only permissions and existing parameter regressions. A separate fresh normal registry verified the actual Slovak UserError and field translation under a non-System payroll user in a READ ONLY transaction, with stored definitions unchanged. Native POT export and SK/CS merge preserve all existing 303 catalog entries. Ruff and git diff --check pass. The documentation generator is absent from this generated repository, so only EN/SK source docs were edited; generated README output was not claimed. OCA only; Enterprise and the 18.0 carry-over are not tested.

The change is generic parameter integrity functionality. No statutory amounts or salary formulas are changed.

Keep matching legacy definitions and earlier/later dates usable. Validate native copy conflicts without changing stored definitions or payroll values.

Assisted-by: OpenAI Codex
Add the ordinary payroll reader regression and preserve existing catalogs while adding the native exported error. Document the effective-date correction workflow.

Assisted-by: OpenAI Codex
@Rad0van

Rad0van commented Nov 18, 2026

Copy link
Copy Markdown
Member

Thank you, this is a real gap and the fix is well scoped. The reader picked limit=1 with order="date_from desc" only, so two rows on the same date left the value to Postgres. Making the order total and refusing a conflicting tie is the right behaviour for statutory values, and keeping matching duplicates readable avoids breaking anyone for no reason.

What we checked on our side:

  • The reader is the only path to parameter values on the OCA engine. payslip.rule_parameter(), the sick-pay tiers in hr_payslip.py, l10n_sk_hr_payroll_income_allocation and l10n_sk_hr_payroll_income_settlement all call _get_parameter_value, and nothing in base, surcharges, MVP, VPP or the declaration modules searches hr.rule.parameter.value directly. So nothing bypasses the new check.
  • OCA payroll itself has no rule-parameter model at all (checked against the live 19.0 branch), so there is no upstream ordering to rely on; this model is ours.
  • Enterprise does not have the ambiguity: hr.rule.parameter.value there carries unique (rule_parameter_id, date_from). So the "Enterprise not tested" notes in the changelog and both docs could simply say that Enterprise rejects such a tie at entry with a unique key; no mirror is needed.
  • On a clean install of SK payroll with surcharges, MVP and VPP no parameter has two rows on one date, and none of roughly seventy local payroll databases we have (OCA and Enterprise, SK, CZ and combined SK+CZ) has a single tie. Existing data should therefore not start raising.
  • The Slovak and Czech messages render correctly at runtime; the catalogues are complete for the new string.

Tests: our baseline on 19.0 is 290 green; with this PR 299 green (your nine new tests included). With only the model change reverted, four of the nine fail (native copy, older conflict, nested type conflict, payroll user), so the tests do guard the fix.

A few suggestions, none of them blocking:

  • Equal numbers of different types count as a conflict: a row 1 next to a row 1.0 on the same date now raises, although every rule computes the same result from either. Keeping bool apart from int is right, but would you consider comparing int and float by value? If you prefer the strict reading, a sentence in the docs saying that 1 and 1.0 are treated as different would save someone a puzzled afternoon.
  • The second search runs on every read, also when there is no tie. We measured about 240 µs per read before and about 390 µs after, and a monthly payslip goes through the reader several dozen times. Searching with order="date_from desc, id", limit=2 gives you the value and tells you in the same query whether a peer exists on that date; only then is the full peer search needed. The common path stays one query.
  • A data-entry check would stop the problem where it is made. Enterprise's models.Constraint("unique (rule_parameter_id, date_from)", ...) is the obvious model; on an existing database with a tie the key is simply not created and Odoo logs it, which is what our 19.0.1.19.0 pre-migration already does for duplicate codes (it reports, it does not merge). That would be a follow-up, not a condition: the reader check stays useful for databases where the key cannot be created yet.
  • In sk.md the menu path reads "Mzdy → Konfigurácia → Parametre pravidiel"; on a plain install with Slovak loaded the payroll root menu is called "Výplatná listina", so either path may confuse a reader. Perhaps name only the last two steps.
  • The second commit's subject (test: …) does not follow the [TAG] module: summary form; we squash on port anyway, so no need to rewrite it.

Version: 19.0.1.26.3 is fine as a placeholder. #54, #55 and #56 each claim a number after 19.0.1.26.2 and we assign the final ones in the order they are ported, so please do not worry about collisions.

Verdict: approve. Happy to merge as is; the int/float point and the limit=2 query would make it better if you have time.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants