def METHOD_NAME(self):
    for move in self:
        move.payment_mode_id = move.payment_mode_id
        if move.company_id and move.payment_mode_id.company_id != move.company_id:
            move.payment_mode_id = False
        if move.partner_id:
            partner = move.with_company(move.company_id.id).partner_id
            if move.move_type == "in_invoice":
                move.payment_mode_id = partner.supplier_payment_mode_id
            elif move.move_type == "out_invoice":
                move.payment_mode_id = partner.customer_payment_mode_id
            elif (
                move.move_type in ["out_refund", "in_refund"]
                and move.reversed_entry_id
            ):
                move.payment_mode_id = (
                    move.reversed_entry_id.payment_mode_id.refund_payment_mode_id
                )
            elif not move.reversed_entry_id:
                if move.move_type == "out_refund":
                    move.payment_mode_id = (
                        partner.customer_payment_mode_id.refund_payment_mode_id
                    )
                elif move.move_type == "in_refund":
                    move.payment_mode_id = (
                        partner.supplier_payment_mode_id.refund_payment_mode_id
                    )