Hi, I'm updating a model from odoo 13 to odoo 14 and I have this function in my account.payment model that inherits from the one in account
@api.depends('invoice_ids', 'payment_type', 'partner_type', 'partner_id') def _compute_destination_account_id(self): # The account used for refunding can be different to receivable account. super()._compute_destination_account_id() for payment in self.filtered(lambda p: p.payment_type == 'outbound' and p.partner_type == 'customer'): if not payment.invoice_ids and payment.partner_id: if payment.partner_id.property_account_refund_id: payment.destination_account_id = payment.partner_id.property_account_refund_id else: raise ValidationError(_("There is no refunding account for {}.").format(payment.partner_id.name))
and this is a snippet from the parent function
@api.depends('invoice_ids', 'payment_type', 'partner_type', 'partner_id') def _compute_destination_account_id(self): self.destination_account_id = False for payment in self: if payment.invoice_ids: payment.destination_account_id = payment.invoice_ids[0].mapped( 'line_ids.account_id').filtered( lambda account: account.user_type_id.type in ('receivable', 'payable'))[0] elif payment.payment_type == 'transfer': if not payment.company_id.transfer_account_id.id: raise UserError(_('There is no Transfer Account defined in the accounting settings. Please define one to be able to confirm this transfer.')) payment.destination_account_id = payment.company_id.transfer_account_id.id elif payment.partner_id: partner = payment.partner_id.with_context(force_company=payment.company_id.id) if payment.partner_type == 'customer': payment.destination_account_id = partner.property_account_receivable_id.id else:
and this is invocie_ids field from the odoo account.payment
invoice_ids = fields.Many2many('account.move', 'account_invoice_payment_rel', 'payment_id', 'invoice_id', string="Invoices", copy=False, readonly=True,help="""Technical field containing the invoice for which the payment has been generated.This does not especially correspond to the invoices reconciled with the payment, as it can have been generated first, and reconciled later""")
in odoo 14 `invoice_ids` has been removed and `account.payment` now inherits from `account.move` using delegate inheritance
class AccountPayment(models.Model):
_name = "account.payment"
_inherits = {'account.move': 'move_id'}
_inherit = ['mail.thread', 'mail.activity.mixin']
_description = "Payments"
_order = "date desc, name desc"
_check_company_auto = True
My question is what should I replace `invoice_ids`, not just in this function but everywhere in the code. there is a new field `move_id` that might be a good candidate but I'm not sure.
move_id = fields.Many2one( comodel_name='account.move', string='Journal Entry', required=True, readonly=True, ondelete='cascade', check_company=True)
I have another question about the upgrade process in general. Currently, while tracking what fields have been deleted or added, I struggle to understand the change and how to adapt my models to it. Where can I find resources that help with the process?