Sunday, June 7, 2020
1 change · master
Resolved issues and error corrections
This fixes a core issue where creating a new record with default linked items could unintentionally move those items away from an existing record. The change helps preserve data relationships and prevents accidental reassignment of records during standard creation flows.
Original PR description
**Description of the issue/feature this PR addresses:**
Create those models
```python
class Order(models.Model)
_name = 'order'
line_ids = fields.One2many(comodel='order.line', inverse='order_id')
class OrderLine(models.Model)
_name = 'order.line'
order_id = fields.Many2one(comodel='order')
```
- create `order(1)`, with `line_ids = order.line(1)`.
- execute `self.env['order'].with_context(default_line_ids=[1]).create({})`.
Result:
`order(1)`, with `line_ids = None`.
`order(2)`, with `line_ids = order.line(1)`.
--> `order(2)` has stolen `order.line(1) `
@odony @rco-odoo
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr