[19.0][FIX] partner_address_street3: copy street3 to child contacts#2352
[19.0][FIX] partner_address_street3: copy street3 to child contacts#2352fsmw wants to merge 7 commits into
Conversation
eea1d95 to
c42b297
Compare
| <field name="inherit_id" ref="base.view_partner_form" /> | ||
| <field name="arch" type="xml"> | ||
| <xpath expr="//field[@name='child_ids']" position="attributes"> | ||
| <attribute name="context">{ |
There was a problem hiding this comment.
Avoid overwriting context from XML, instead use default_get
There was a problem hiding this comment.
Can you explain how you would do that?
There was a problem hiding this comment.
Just Move all the logic to python side using default_get method and in this method, add default value for street3 field
150c436 to
9614333
Compare
| for field in self._address_fields(): | ||
| if ( | ||
| field in default_fields | ||
| and field in parent._fields |
|
Removed the redundant |
66849a0 to
a4472c0
Compare
0a47e09 to
5ee6df1
Compare
| res.append("street3") | ||
| return res | ||
|
|
||
| @api.onchange("parent_id") |
There was a problem hiding this comment.
This will result in onchange_parent_id being called twice. First under its own name, then through the super() call here.
NL66278
left a comment
There was a problem hiding this comment.
Please leave the module partner_category_description intact.
|
@NL66278 thanks for the catch — both issues addressed in 2 new commits on top of the branch: 1. 2. Replaced the onchange override with New approach: Re-requesting your review. |
…t_view for street3 copy
Replace the default_get override (which fails with unsaved parents/NewId)
and the get_view override (which injected default_street3 into child_ids
context via lxml) with a simple onchange("parent_id") that extends
base's onchange_parent_id to ensure street3 is always copied.
The base onchange_parent_id already copies all _address_fields(), but
the explicit setdefault guarantees street3 is included even when it's
the only address field set on the parent.
Co-authored-by: BhaveshHeliconia <bhavesh@heliconia.io>
In Odoo 19, onchange_parent_id() returns {} instead of None.
Move the 'or {}' fallback after the parent_id check so the
method preserves the base return value when there is no parent.
Update tests to assert no street3 is added rather than asserting
exact return type, making them compatible across Odoo versions.
…arent_id
The previous onchange("parent_id") override never ran in the inline
"Add in Contacts & Addresses" form, because parent_id is delivered
via default_parent_id in the context, not via an interactive onchange.
That is why the original issue (OCA#2298) — street3 not prefilled in the
inline create dialog — was not actually fixed.
Replace the onchange override with a default_get that reads
default_parent_id from the context and copies the address fields,
guarded by 'if not values.get(field)' so explicit defaults are not
clobbered. This matches the suggestion from BhaveshHeliconia and
addresses the 'onchange_parent_id called twice' concern raised by
NL66278 (the override was redundant with the base behaviour anyway).
Tests rewritten around default_get to cover the inline create context
and the no-clobber guarantee.
2a60585 to
16282c0
Compare
|
Conflicts resolved. Rebased on top of upstream/19.0 (HEAD CI is now running on the rebased branch. |
…ult_get_no_parent
|
@NL66278 @BhaveshHeliconia — el rebase 16282c0 → 88854b7 también arregla el lint de ruff E501 (línea 113 del test) que estaba bloqueando el merge. La nueva línea 113-117 ahora pasa ruff. CI re-corrida. |
Could you please explain this in English? |
|
@BhaveshHeliconia sorry, slipped into Spanish by mistake. Here's the English version: The rebase 16282c0 → 88854b7 also fixes the ruff E501 lint (line 113 of the test) that was blocking the merge. The new lines 113-117 now pass ruff. CI has been re-run. |
…r street3 copy
The onchange("parent_id") override (commit f524e12) does not fire in the
inline 'Add in Contacts & Addresses' form: that flow passes default_parent_id
in the context and never triggers a user-driven onchange, so street3 was
still not copied when adding a contact to an unsaved parent (as confirmed
by BhaveshHeliconia on 2026-05-21).
Replace the onchange with a default_get override that reads default_parent_id
from the context and copies all _address_fields() (including street3),
guarded by 'if not values.get(field)' so explicit defaults still win.
This mirrors the approach used in the 19.0 sister PR OCA#2352 (commit 16282c0),
which was reviewed and validated in the same scenario.
|
Hi @NL66278 — gentle ping. Your Subsequent commits on top:
CI is green on the rebased branch. Mind taking another look to clear the CHANGES_REQUESTED? Happy to address any further feedback. |
When creating a child contact via the 'Contacts & Addresses' kanban view, the street3 field was not being copied from the parent company.
This is because street3 was missing from the child_ids context defaults. Overwriting the view context attribute via XML view inheritance has a high risk of conflicting with other modules doing the same.
Fix
Implement a Python-only
default_getoverride inres.partnerto copystreet3(and other address fields in_address_fields()) from the parent partner when creating a child contact (i.e. whendefault_parent_idis present in the context).Changes
models/res_partner.py: Overridedefault_getto populate address fields from parent ifdefault_parent_idis settests/test_street_3.py: Regression test verifyingstreet3is copied when creating child contacts viadefault_getFixes #2298