Skip to content

[18.0][FIX] contract: restore the option to hide the discount column - #1516

Open
bosd wants to merge 1 commit into
OCA:18.0from
bosd:18.0-fix-contract-discount-option
Open

[18.0][FIX] contract: restore the option to hide the discount column#1516
bosd wants to merge 1 commit into
OCA:18.0from
bosd:18.0-fix-contract-discount-option

Conversation

@bosd

@bosd bosd commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Same fix as #1514, for 18.0 - this is the series where the regression was introduced.

Problem

The discount column on contract lines cannot be hidden.

Up to 17.0 it could: the field carried groups="product.group_discount_per_so_line" in every view. The 18.0 migration (1dd820b) dropped that attribute from all five places - Odoo had moved the group from product to sale, so the old xmlid stopped resolving - and the column has been unconditionally visible ever since.

readme/CONFIGURE.md was never updated and still tells users:

To view discount field in contract line, you need to set Discount on lines in user access rights.

which has not been true since the migration.

Change

contract depends on product, not sale, so it cannot use the core group any more without pulling in a dependency it has no other use for. It owns one instead:

  • contract.group_discount_per_contract_line, exposed as a Discounts toggle in the (previously empty) Contract block of the Invoicing settings.
  • groups= restored on the discount field in the contract form's two embedded line lists, the contract line form, the contract template and the contract template line.
  • The group is granted to internal users in the data file, so nothing changes on upgrade - discounts stay visible until someone unticks the setting.
  • CONFIGURE.md rewritten to describe the setting that now exists.
  • Test covering the default and both directions of the toggle.

Two levels, on purpose

The group answers may discounts be used on this database at all - a decision for the whole install, made once in the settings.

That is not the same question as do I want this column right now. Even where discounts are allowed, the column costs list width a user may prefer to spend elsewhere. So the discount field also gets optional="show" in the four line lists: the two embedded lists on the contract form, the contract line list and the contract template line list.

The lists look exactly as they do today; the difference is that the column can be dropped from the column selector, remembered per user. The two form views keep no optional, where it would mean nothing.

Up to 17.0 the discount field carried
`groups="product.group_discount_per_so_line"`, so it could be hidden. The
18.0 migration dropped that attribute - Odoo had moved the group from
`product` to `sale` and the old xmlid no longer resolved - and the discount
column has been unconditionally visible since, even though CONFIGURE.md
still told users they could switch it off.

`contract` depends on `product`, not on `sale`, so it cannot use the core
group any more without dragging in a dependency it has no other use for.
Own the group instead: `contract.group_discount_per_contract_line`, gated
behind a *Discounts* setting in the contract block of the Invoicing
settings, and applied to the discount field on contract lines, contract
template lines and both embedded line lists on the contract form.

The group is granted to internal users in the data file, so installs that
upgrade keep seeing discounts and only lose them when the setting is
unticked. Update CONFIGURE.md, which described the removed behaviour.

The group says whether discounts may be used at all, which is a decision
for the whole database. On top of that, give the column `optional="show"`
in the four line lists, so a user who is allowed to see discounts can still
drop the column to save width. The lists look the same as before; the
choice is remembered per user. The field keeps no `optional` on the two
form views, where it would mean nothing.
@bosd
bosd force-pushed the 18.0-fix-contract-discount-option branch from a99a1e9 to 0f482a4 Compare September 5, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants