Skip to content

[17.0][ADD] partner_owner_company: soft alternative to company_id - #2271

Open
dreispt wants to merge 3 commits into
OCA:17.0from
ursais:17-dr-partner_owner_company
Open

dreispt wants to merge 3 commits into
OCA:17.0from
ursais:17-dr-partner_owner_company

Conversation

@dreispt

@dreispt dreispt commented Jan 21, 2026

Copy link
Copy Markdown
Member

No description provided.

@dreispt
dreispt force-pushed the 17-dr-partner_owner_company branch from 1343d97 to 564ad38 Compare February 6, 2026 19:25

@luisDIXMIT luisDIXMIT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM but pre-commit is failing.

<xpath expr="//field[@name='category_id']" position="after">
<field
name="owner_company_id"
options="{'no_create': True, 'no_create_edit': True}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think if it is a company, it should be invisible, following the logic in the tree view.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @dreispt, don’t you think so?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't follow - if the field is not visible, the users won't be able to the owner company on it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with @luisDIXMIT. We should use base.group_multi_company on owner_company_id field same as odoo does for 'company_id' field. For only one single company, no need to show this field in view.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I understand now. Yes, that makes sense,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry for taking so long, but what I mean is: if a contact is a company, why can’t I see the company it belongs to in the tree view, even though I can see it in the form view?

image image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see, added a fix for that.

@dreispt
dreispt force-pushed the 17-dr-partner_owner_company branch from 564ad38 to 638d82f Compare February 26, 2026 22:08
@BhaveshHeliconia

BhaveshHeliconia commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

I've found one issue

  • Steps to reproduce:
    • Create a contact with child contact. No owner_company_id set in both.
    • Try to search for parent contact in any contact dropdown(sale/purchase/invoice).
    • Observe that only child contact is there, not parent contact.

Possible enhancements:

  • owner_company_id should be in sync between parent and child contacts.

@dreispt

dreispt commented May 21, 2026

Copy link
Copy Markdown
Member Author

I've found one issue

I will check.

Possible enhancements:

That probably makes sense.

@dreispt dreispt self-assigned this May 21, 2026
@dreispt
dreispt force-pushed the 17-dr-partner_owner_company branch from 638d82f to f8ef94d Compare May 26, 2026 09:20
@OCA-git-bot OCA-git-bot added series:17.0 mod:partner_owner_company Module partner_owner_company labels May 26, 2026
@dreispt

dreispt commented May 26, 2026

Copy link
Copy Markdown
Member Author

Corrections were added.

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now, parent contact is there, but found following issue:
If we have one parent contact having owner_company_id set(Same as current company) and its one child contact having different owner_company_id than parent and we try to search child contact using partial name and 'Search More' option from many2one dropdown, child contact is there. As per the docs, other company contacts should only be searched by full name/email/reference/VAT.

@dreispt

dreispt commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

@BhaveshHeliconia
Child contacts should "inherit" the same owner as the parent.
So the behavior looks correct.
Perhaps the field should be disabled/invisible for child contacts, for better UX?

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dreispt I agree with you on disabling/hiding the owner_company_id field for child contacts. However, I think its value should still be synced from the parent contact (parent_id.owner_company_id) to keep the data consistent.

Also, could you please confirm whether the following behaviour is expected?

  • We have two contacts with different owner_company_id values: ContactA and ContactB.
  • Each contact has one child contact with the same owner_company_id as its parent: ChildA and ChildB.
  • We then set ContactA's owner_company_id to the current company and go to the Sale Order's Customer field dropdown.
  • In the dropdown, we can search for ContactA and ChildA using a partial name, while ContactB and ChildB require a full name search. This seems to be the expected behaviour according to the documentation.
  • However, when we click Search More and perform the same partial-name search, all contacts are returned.

Could you please confirm whether this is the intended behaviour of the module or if it is a bug that should be fixed?

If this is intentional, I think it would be helpful to mention this behaviour explicitly in the documentation.

@dreispt

dreispt commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Indeed, the implementation applies for name search only.
So that behavior is expected.

I agree it would be better for childs to inherit the parent owner_id automatically, and that the doc could be improved as you describe.

@BhaveshHeliconia

Copy link
Copy Markdown
Contributor

Okay, thanks for the info. Rest looks good to me. Just doc update and we're good to go.

@dreispt dreispt changed the title [ADD] partner_owner_company: soft alternative to company_id [17.0][ADD] partner_owner_company: soft alternative to company_id Nov 20, 2026
Add soft company ownership for contacts without imposing access restrictions.
Filter dropdown autocomplete by owner company, with an exact-match fallback
for contacts owned by other companies.

Document that Search More and the Contacts list do not apply owner-company
filtering, as clarified during review.

Assisted-by: Devin:GPT-6.1
@dreispt
dreispt force-pushed the 17-dr-partner_owner_company branch 3 times, most recently from e61198b to ba91c12 Compare November 20, 2026 11:16
Child contacts could store a different owner from their parent, making
stored ownership and company grouping inconsistent with dropdown searches.
Creating a child or changing its parent did not inherit the parent owner,
and changes to the parent owner did not reach existing children.

Resolve the top-level contact once and update its direct children.
Their writes recursively propagate ownership down the hierarchy without
restarting from the root. Include archived children and update every
child so stale descendants under consistent intermediates are repaired.

Make child ownership read-only. Detaching a contact retains its last
inherited owner so it can then be managed independently.

Add seven acceptance tests covering inheritance, propagation, clearing,
reparenting, child overrides, batch updates, dropdown behavior, and
root-based repair of legacy ownership. Failing regressions were confirmed
before implementation; all seven tests pass on Odoo 17.
Focused pre-commit checks also pass.

Assisted-by: Devin:GPT-6.1
Assisted-by: Devin:SWE-2 Flash Max
@dreispt
dreispt force-pushed the 17-dr-partner_owner_company branch from ae1c9d1 to e86bba6 Compare November 20, 2026 11:37
@dreispt

dreispt commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Docs were updated.
A commit was added to implement owner_id sync across children.

The list view hid the owner company cell for every company contact, but
company contacts can have a parent and inherit an owner company just
like any other child contact. The form view already shows the value,
so the list view hid information that is meaningful for child
companies. Drop the invisible condition so the column behaves the
same for all contacts.

Assisted-by: Devin:SWE-2 Flash Medium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants