Skip to content

[15.0][IMP] onchange_helper: Support one2many fields in onchanges#3515

Open
pedrobaeza wants to merge 1 commit intoOCA:15.0from
Tecnativa:15.0-imp-base_onchange_helper-o2m
Open

[15.0][IMP] onchange_helper: Support one2many fields in onchanges#3515
pedrobaeza wants to merge 1 commit intoOCA:15.0from
Tecnativa:15.0-imp-base_onchange_helper-o2m

Conversation

@pedrobaeza
Copy link
Member

@pedrobaeza pedrobaeza commented Feb 4, 2026

There are one2many fields that are computed, like for example sale.order.line~agent_ids in module sale_commission. When another module like sale_product_set uses this module to populate the order lines, you get this error:

odoo.sql_db: bad query: INSERT INTO "sale_order_line_agent" ("id", "create_date", "create_uid", "object_id", "write_date", "write_uid") VALUES (nextval('sale_order_line_agent_id_seq'), ...) RETURNING id
odoo-1  | ERROR: null value in column "agent_id" of relation "sale_order_line_agent" violates not-null constraint

And this is because the commands that are passed consists on just (0, 0, {}).

This commit fixes this acting in 2 places:

  • Populating correctly the onchange_spec to get those fields.
  • Manipulating afterwards o2m fields the same way it's done with the first level to clean many2one values from (id, display_name) to just the id.

@Tecnativa TT60729

There are one2many fields that are computed, like for example
`sale.order.line~agent_ids` in module `sale_commission`. When another
module like `sale_product_set` uses this module to populate the order
lines, you get this error:

```
odoo.sql_db: bad query: INSERT INTO "sale_order_line_agent" ("id", "create_date", "create_uid", "object_id", "write_date", "write_uid") VALUES (nextval('sale_order_line_agent_id_seq'), ...) RETURNING id
odoo-1  | ERROR: null value in column "agent_id" of relation "sale_order_line_agent" violates not-null constraint
```

And this is because the commands that are passed consists on just
`(0, 0, {})`.

This commit fixes acting in 2 places:

- Populating correctly the onchange_spec to get those fields.
- Manipulating afterwards o2m fields the same way it's done with the
  first level to clean many2one values from `(id, display_name)` to just
  the id.

TT60729
@pedrobaeza pedrobaeza added this to the 15.0 milestone Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant