Sélectionner une révision Git
scop_deces_wizard.py 1,17 Kio
# © 2020 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class ScopDecesWizard(models.TransientModel):
_inherit = "scop.deces.wizard"
def deces_action(self):
super().deces_action()
partner_id = self.env["res.partner"].browse(self.partner_id)
mandate_ids = self.env["account.banking.mandate"].search(
[
("partner_id", "=", partner_id.id),
("state", "=", "valid"),
("company_id", "=", self.env.company.id),
]
)
if mandate_ids:
for mandate in mandate_ids:
mandate.update({"state": "expired"})
invoice_ids = self.env["account.move"].search(
[
("mandate_id", "=", mandate.id),
("move_type", "in", ("out_invoice", "out_refund")),
("state", "in", ("draft", "posted")),
("payment_state", "in", ("draft", "not_paid", "partial")),
]
)
mandate._remove_invoice_mandate(invoice_ids)