Skip to content

[19.0][IMP] contract: restrict pricelist selection to the contract's company#1488

Open
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-imp-contract-pricelist-company-domain
Open

[19.0][IMP] contract: restrict pricelist selection to the contract's company#1488
bosd wants to merge 1 commit into
OCA:19.0from
bosd:19.0-imp-contract-pricelist-company-domain

Conversation

@bosd

@bosd bosd commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Problem

pricelist_id on contract.contract and contract.template has no company domain, so a pricelist belonging to any company can be selected on a contract — including a company whose pricelists the contract's users can't read. That silently creates cross-company records which later raise a product pricelist company rule access error (typically when a line's price is computed and the foreign-company pricelist is read).

Fix

Add the same company domain Odoo's sale.order.pricelist_id uses:

<field name="pricelist_id" domain="[('company_id', 'in', (company_id, False))]"/>

on both the contract form and the contract-template form — restricting selection to the record's own company or a shared (company-less) pricelist. company_id is auto-included by the view for the domain (as it is for sale.order).

Preventive only — it doesn't migrate existing mismatched data; that's a one-off data fix.

@pedrobaeza pedrobaeza added this to the 19.0 milestone Jul 17, 2026

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot be this managed by check_company or similar attribute?

The pricelist_id field on contract.contract and contract.template had no
company domain, so a pricelist from any company could be selected -- including
a company the contract's users cannot read. That silently creates cross-company
records that later raise "product pricelist company rule" access errors (e.g.
when a line's price is computed).

Add the standard company domain (mirroring sale.order.pricelist_id):
domain="[('company_id', 'in', (company_id, False))]" -- the contract's own
company or a shared (company-less) pricelist.
@bosd
bosd force-pushed the 19.0-imp-contract-pricelist-company-domain branch from 706ddca to bf7fa85 Compare July 17, 2026 14:24
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.

3 participants