mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[Ref](https://github.com/odoo/odoo/commit/cb76725b071d8#diff-1e3bd6be3bfb83a37ec9fb800ce8b1c95afe0be90ff792874ae7299c320a2f6eR2257) [REF] Direct Debit Mandate should be editable on the invoice form
32 lines
973 B
Python
32 lines
973 B
Python
# Copyright 2020 Marçal Isern <marsal.isern@qubiq.es>
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
|
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class AccountMove(models.Model):
|
|
_inherit = "account.move"
|
|
|
|
mandate_id = fields.Many2one(
|
|
"account.banking.mandate",
|
|
string="Direct Debit Mandate",
|
|
ondelete="restrict",
|
|
readonly=False,
|
|
check_company=True,
|
|
states={"draft": [("readonly", False)]},
|
|
compute="_compute_mandate_id",
|
|
store="True",
|
|
)
|
|
mandate_required = fields.Boolean(
|
|
related="payment_mode_id.payment_method_id.mandate_required", readonly=True
|
|
)
|
|
|
|
@api.depends("payment_mode_id", "partner_id")
|
|
def _compute_mandate_id(self):
|
|
for move in self:
|
|
if move.payment_mode_id.payment_method_id.mandate_required:
|
|
move.mandate_id = move.partner_id.valid_mandate_id
|
|
else:
|
|
move.mandate_id = False
|