Skip to content

Commit

Permalink
[FIX] website_sale: delete explicitely change return_path
Browse files Browse the repository at this point in the history
In the case of deletion with `ondelete="set null"`, return_path of
children of deleted record will not have return_path updated.

So remove the parent explicitely so the ORM know to update them.

note: in master the parent_id field of product.public.category will be
set to `ondelete="cascade"`.

opw-2148046
closes odoo#41075

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
  • Loading branch information
nle-odoo committed Nov 29, 2019
1 parent 6ae7913 commit 6d5cd8b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions addons/website_sale/models/product.py
Expand Up @@ -163,6 +163,10 @@ def name_get(self):
res.append((category.id, " / ".join(category.parents_and_self.mapped('name'))))
return res

def unlink(self):
self.child_id.parent_id = None
return super(ProductPublicCategory, self).unlink()

def _compute_parents_and_self(self):
for category in self:
if category.parent_path:
Expand Down

0 comments on commit 6d5cd8b

Please sign in to comment.