Description of the issue/feature this PR addresses: When an expense was accepted and then the account move related to the expense was reset to draft/cancelled, the expense's state stayed as payed. Current behavior before PR: The expense's state stayed as payed. Desired behavior after PR is merged: Change the expense's state to refused with the reason 'Payment Cancelled'. opw-2559225 closes odoo/odoo#77729 X-original-commit: cfe95a0e3781a23be73541cdae4393b8507cf9c1 Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
15 lines
397 B
Python
15 lines
397 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models, _
|
|
|
|
|
|
class AccountMove(models.Model):
|
|
_inherit = "account.move"
|
|
|
|
def button_cancel(self):
|
|
for l in self.line_ids:
|
|
if l.expense_id:
|
|
l.expense_id.refuse_expense(reason=_("Payment Cancelled"))
|
|
return super().button_cancel()
|