Skip to content

[19.0][MIG] partner_property: Migration to 19.0#2358

Open
dnplkndll wants to merge 22 commits into
OCA:19.0from
ledoent:19.0-mig-partner_property
Open

[19.0][MIG] partner_property: Migration to 19.0#2358
dnplkndll wants to merge 22 commits into
OCA:19.0from
ledoent:19.0-mig-partner_property

Conversation

@dnplkndll
Copy link
Copy Markdown

@dnplkndll dnplkndll commented May 20, 2026

Port of partner_property from 18.0 to 19.0. Follows the OCA migration guide.

Non-mechanical adaptations worth flagging

  • _search_properties_company_id — 19.0's Domain optimizer normalises (field, '=', value) to (field, 'in', {value}) before reaching the search method, so the operator == '=' guard never fired and partners without an explicit company_id were silently excluded from the implicit-match branch. Now accepts both shapes.
  • _search_partner_properties_definition_{company,person}Domain.TRUE is falsy in bool context (sentinel: __bool__ returns not self.is_true()), so cond and Domain.TRUE or Domain.FALSE always evaluated to Domain.FALSE. Rewrote with an explicit ternary + XOR on (empty, negate). Also accepts the in/not in shapes post-optimizer-normalisation.

19.0 relevance

res.partner now inherits properties.base.definition.mixin (single global properties field). This module adds per-company properties_type_{company,person} fields keyed off env.company, plus the person/company-type split — distinct from core. Open question for reviewers: expose all three properties fields, or hide the core one.

victoralmau and others added 19 commits May 20, 2026 19:02
…ner_property.properties_definition_person)

Related to OCA@d3e2fe8

TT49480
Currently translated at 100.0% (7 of 7 strings)

Translation: partner-contact-16.0/partner-contact-16.0-partner_property
Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_property/it/
Before this commit, the field properties marked as "Display in Cards" were not displayed in the kanban view.
After this commit, the field properties marked as "Display in Cards" are displayed correctly in the kanban view.
Steps to reproduce:

1. Go in the partner or users list view
2. Select a few records
3. Click on Actions > Export

Expected:

The Export wizard should open.

Result:

```
File "/odoo/src/odoo/addons/web/controllers/export.py", line 400, in get_fields
    exportable_fields.update(self._get_property_fields(fields, model, domain=domain))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/odoo/src/odoo/addons/web/controllers/export.py", line 321, in _get_property_fields
    field_to_get = Model._field_to_sql(Model._table, definition_record, self_subquery)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/odoo/src/odoo/odoo/models.py", line 2976, in _field_to_sql
    raise ValueError(f"Cannot convert {field} to SQL because it is not stored")
ValueError: Cannot convert res.partner.properties_company_id to SQL because it is not stored
```
Originally attempted to fix it here: 36b93fa

But that fix only worked for res.partners due to not properly using the alias
in the `_field_to_sql` method.

Then, when trying to export res.users (or any model that inherits from
res.partner), we'd get the following error:

```
  File ".../odoo/addons/web/controllers/export.py", line 324, in _get_property_fields
    definition_records = target_model.search_fetch(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../odoo/odoo/models.py", line 1781, in search_fetch
    return self._fetch_query(query, fields_to_fetch)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../odoo/odoo/models.py", line 4240, in _fetch_query
    rows = self.env.execute_query(query.select(*sql_terms))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../odoo/odoo/api.py", line 993, in execute_query
    self.cr.execute(query)
  File ".../odoo/odoo/sql_db.py", line 582, in execute
    return self._cursor.execute(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../odoo/odoo/sql_db.py", line 357, in execute
    res = self._obj.execute(query, params)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.AmbiguousColumn: column reference "company_id" is ambiguous
LINE 1: ...TRUE) AND ("res_company"."id" IN (SELECT COALESCE(company_id...
```
Currently translated at 100.0% (7 of 7 strings)

Translation: partner-contact-18.0/partner-contact-18.0-partner_property
Translate-URL: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-partner_property/es/
@dnplkndll dnplkndll marked this pull request as draft May 20, 2026 23:09
@dnplkndll dnplkndll force-pushed the 19.0-mig-partner_property branch 6 times, most recently from 18345b9 to 20a88c3 Compare May 21, 2026 13:18
Signed-off-by: Don Kendall <dkendall@ledoweb.com>
@dnplkndll dnplkndll force-pushed the 19.0-mig-partner_property branch from 20a88c3 to a319fbd Compare May 21, 2026 13:34
@dnplkndll dnplkndll marked this pull request as ready for review May 21, 2026 13:41
@dnplkndll
Copy link
Copy Markdown
Author

@ivantodorovich @pedrobaeza @victoralmau — this is ready for review.

@pedrobaeza
Copy link
Copy Markdown
Member

On 19, there's already properties in the contacts. Why migrating this?

@dnplkndll
Copy link
Copy Markdown
Author

per-company properties_type_{company,person}

is adds per company. I could not find any real specific cases to know if that was of value. just getting back into practice doing MIGs

will close if there is not a use case for the partner property in company context.

@pedrobaeza
Copy link
Copy Markdown
Member

Well, the value of this module is to have different properties per contacts of type company and of type contact, so if that's not respected upstream, then please go ahead and continue with the migration, but add in CONTEXT.md the reason of this module.

@dnplkndll dnplkndll force-pushed the 19.0-mig-partner_property branch 3 times, most recently from d3344b3 to 6011a5c Compare May 26, 2026 01:03
@dnplkndll
Copy link
Copy Markdown
Author

Well, the value of this module is to have different properties per contacts of type company and of type contact, so if that's not respected upstream, then please go ahead and continue with the migration, but add in CONTEXT.md the reason of this module.

added the verified impact in CONTEXT.md

@dnplkndll dnplkndll force-pushed the 19.0-mig-partner_property branch 2 times, most recently from 37f495a to 79bf6c7 Compare May 29, 2026 20:10
Copy link
Copy Markdown
Contributor

@BhaveshHeliconia BhaveshHeliconia left a comment

Choose a reason for hiding this comment

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

In Odoo 19, properties added from the Contacts form are displayed on all contact records, regardless of any other criteria.

This module extends that behavior by allowing properties to be associated with a specific company_type. As a result, a property created for contacts with company_type = 'company' will only be displayed on contacts of that type and not on contacts with a different company_type.

Possible enhancements

  • The Contacts form currently shows two Add Property buttons: the standard Odoo button and the one introduced by this module. Making them more clearly distinguishable would improve usability.
  • Likewise, properties created through the module-specific button could be visually differentiated from standard Odoo properties to make their origin and behavior more obvious to users.

@dnplkndll dnplkndll force-pushed the 19.0-mig-partner_property branch 2 times, most recently from f8f290a to 8e183fd Compare June 2, 2026 19:34
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<notebook position="before">
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.

Can we add a new notebook tab for this?

dnplkndll added 2 commits June 3, 2026 07:45
- `_search_partner_properties_definition_{company,person}`: refactor to a
  shared fallback helper. The 19.0 Domain optimizer normalises
  `('field', '=', False)` to `('field', 'in', {False})` before reaching the
  search method, so the helper accepts both shapes. Also avoids the
  `Domain.TRUE.__bool__` sentinel trap (`cond and Domain.TRUE or
  Domain.FALSE` always picked `Domain.FALSE`).
- `_search_properties_company_id`: accept the `in` shape post-optimizer
  normalisation in the implicit-match branch.
- `_field_to_sql`: drop the `flush` keyword arg and rename `fname` ->
  `field_expr` to match the 19.0 signature.
- Replace `from odoo.osv.expression import FALSE_DOMAIN, TRUE_DOMAIN` with
  `from odoo.fields import Domain` (19.0 osv.expression deprecation).
- Add tests for the fallback helper and for the compute/inverse/
  web_search_read round-trip on the definition fields.

Signed-off-by: Don Kendall <dkendall@ledoweb.com>
…texts

In Odoo 19.0 the web_search_read method is layered onto BaseModel by
the web addon at server-startup; direct invocation from a test (no web
service mounted) leaves super() without that method, raising
AttributeError on the override's super().web_search_read() call.

Wrap the super() invocation in getattr(super(), 'web_search_read', None)
and fall back to an equivalent search() + read() shape when the web
layer isn't present. The domain-rewrite logic above (selecting the
current company when filtering by partner_properties_definition_*)
runs identically in both paths.

Fixes test failure:
  ERROR: TestResPartnerProperty.test_definition_field_roundtrip_and_web_search
@dnplkndll dnplkndll force-pushed the 19.0-mig-partner_property branch from 8e183fd to e632163 Compare June 3, 2026 11:46
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.