[18.0][FIX] contract: restore the option to hide the discount column - #1516
Open
bosd wants to merge 1 commit into
Open
[18.0][FIX] contract: restore the option to hide the discount column#1516bosd wants to merge 1 commit into
bosd wants to merge 1 commit into
Conversation
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
force-pushed
the
18.0-fix-contract-discount-option
branch
from
September 5, 2026 12:32
a99a1e9 to
0f482a4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fromproducttosale, so the old xmlid stopped resolving - and the column has been unconditionally visible ever since.readme/CONFIGURE.mdwas never updated and still tells users:which has not been true since the migration.
Change
contractdepends onproduct, notsale, 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.CONFIGURE.mdrewritten to describe the setting that now exists.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.