[FIX] account_asset_management: Proper asset unlink + move unlink
2 related fixes: - When removing an asset line depreciation move, we have to pass it first to draft, or we won't be able to remove it even with the context. - When removing a move, the check for removing the linked asset should be only for purchase documents, not for "not sale" documents.
This commit is contained in:
parent
3945771c61
commit
2aa11d4e40
@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
"name": "Assets Management",
|
||||
"version": "13.0.1.3.1",
|
||||
"version": "13.0.1.3.2",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["account"],
|
||||
"excludes": ["account_asset"],
|
||||
|
@ -280,6 +280,7 @@ class AccountAssetLine(models.Model):
|
||||
def unlink_move(self):
|
||||
for line in self:
|
||||
move = line.move_id
|
||||
move.button_draft()
|
||||
move.with_context(force_delete=True, unlink_from_asset=True).unlink()
|
||||
# trigger store function
|
||||
line.with_context(unlink_from_asset=True).write({"move_id": False})
|
||||
|
@ -92,7 +92,7 @@ class AccountMove(models.Model):
|
||||
move.message_post(body=message)
|
||||
|
||||
def button_draft(self):
|
||||
invoices = self.filtered(lambda r: not r.is_sale_document())
|
||||
invoices = self.filtered(lambda r: r.is_purchase_document())
|
||||
if invoices:
|
||||
invoices.line_ids.asset_id.unlink()
|
||||
super().button_draft()
|
||||
|
Loading…
Reference in New Issue
Block a user